Skip to content

Instantly share code, notes, and snippets.

@hinrik

hinrik/curry.p6 Secret

Last active June 10, 2016 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hinrik/a8ce1c656d4cc88e96f7df87004b0f67 to your computer and use it in GitHub Desktop.
Save hinrik/a8ce1c656d4cc88e96f7df87004b0f67 to your computer and use it in GitHub Desktop.
sub print ($a, $b = False) {
# uncommenting this takes the runtime from 0.15s to 0.6s
#my &reprint = &print.assuming(*, $b);
given $a {
when Array {
'[' ~ join(',', $a.map({ print($_) })) ~ ']';
}
when Hash {
'{' ~ $a.map({.key ~ print(.value)}) ~ '}'
}
default { $a.gist }
}
}
say print { foo => 'bar', baz => ['bla','sdf', {a => 'b', c => ['z']}]};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment