Created
January 3, 2012 03:32
-
-
Save colomon/1553342 to your computer and use it in GitHub Desktop.
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
# in Rakudo you can't pass a Mu to where an Array is expected, | |
# so we add multis for explicit undefined values | |
multi sub mirror(Any:U $a, Any:U $b) { return True; } #OK not used | |
multi sub mirror(Any:U $a, @b) { return False; } #OK not used | |
multi sub mirror(@a, Any:U $b) { return False; } #OK not used | |
multi sub mirror(@first, @second) { | |
if (@first|@second == (Mu,)) { | |
return @first == @second ; | |
} | |
mirror(left(@first),right(@second)) and mirror(right(@first),left(@second)) | |
} | |
ok mirror(Mu,Mu),"mirror works with empty trees"; # fails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment