Skip to content

Instantly share code, notes, and snippets.

@grondilu
Last active January 4, 2016 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grondilu/8539314 to your computer and use it in GitHub Desktop.
Save grondilu/8539314 to your computer and use it in GitHub Desktop.
proto fringe($) { {*} }
multi fringe (Pair $node) { fringe $_ for $node.kv }
multi fringe (Any $leaf) { $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;
@grondilu
Copy link
Author

see previous revisions for lazy variations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment