Created
December 12, 2015 12:49
-
-
Save LLFourn/99f4ccf32de604bc61b2 to your computer and use it in GitHub Desktop.
recursively grep arrays with test
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
use v6; | |
sub deepgrep(&test,@array) { | |
@array.map: { | |
when Positional { |deepgrep(&test, $_) } | |
default { $_ when test $_ } | |
} | |
} | |
say deepgrep * %% 2, [[1], 2, [[3,4], 5], | |
[[[]]], [[[6]]], 7, 8, []]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment