Skip to content

Instantly share code, notes, and snippets.

@colomon
Forked from grondilu/fringe.p6
Created January 21, 2014 13:29
Show Gist options
  • Save colomon/8540035 to your computer and use it in GitHub Desktop.
Save colomon/8540035 to your computer and use it in GitHub Desktop.
proto fringe($) { gather { {*} } }
multi fringe (Pair $node) { take fringe $_ for $node.kv }
multi fringe (Any $leaf) { take $leaf }
sub samefringe ($a, $b) { fringe($a) eqv fringe($b) }
my $a = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8;
my $b = 1 => (( 2 => 3 ) => (4 => (5 => ((6 => 7) => 8))));
my $c = (((1 => 2) => 3) => 4) => 5 => 6 => 7 => 8;
my $x = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8 => 9;
my $y = 0 => 2 => 3 => 4 => 5 => 6 => 7 => 8;
my $z = 1 => 2 => (4 => 3) => 5 => 6 => 7 => 8;
use Test;
plan 6;
ok samefringe $a, $a;
ok samefringe $a, $b;
ok samefringe $a, $c;
nok samefringe $a, $x;
nok samefringe $a, $y;
nok samefringe $a, $z;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment