Last active
January 4, 2016 00:08
-
-
Save grondilu/8539314 to your computer and use it in GitHub Desktop.
same fringe test. See http://rosettacode.org/wiki/Same_Fringe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see previous revisions for lazy variations