-
-
Save holli-holzer/8a69c6ea46782873ec21d02c8785026e 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
my $tree = { | |
v => 1, | |
l => { | |
v => 2, | |
l => { | |
v => 4, | |
r => { v => 7 }, | |
}, | |
r => { | |
v => 3, | |
l => { v => 5 }, | |
r => { v => 6 }, | |
} | |
}, | |
}; | |
sub walk($hash, &block) | |
{ | |
$hash.█ | |
.&walk(&block) for grep *.so, $hash<l>, $hash<r>; | |
} | |
my $sum = sum gather $tree.&walk({ take .<v> }); | |
$tree.&walk({ .<v> = $sum - .<v> }); | |
dd $tree; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment