-
-
Save moritz/8ab4e598ec74f2893b76ba3efe4fc44f to your computer and use it in GitHub Desktop.
Change hash keys recursively in Raku #rakulang
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 %input = ( | |
'a-b' => [2, { 'b-c' => 'd-x' }] | |
); | |
multi change-keys(%input, &changer) { | |
%input.map(-> $p { changer($p.key) => change-keys($p.value, &changer) }).hash | |
} | |
multi change-keys(@input, &changer) { | |
@input.map(-> $x { change-keys($x, &changer)}).list; | |
} | |
multi change-keys($input, &changer) { $input } | |
say change-keys(%input, { .subst('-', '_') }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment