Created
January 26, 2010 18:41
-
-
Save uasi/287089 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
multi sub grep ($cond, @array, :@between where { .elems == 2 }) { | |
my $level = 0; | |
gather for @array { | |
$level-- if $level && $_ ~~ @between[1]; | |
take $_ if $level && $_ ~~ $cond; | |
$level++ if $_ ~~ @between[0]; | |
} | |
} | |
grep *, <a ( b ( c d ) ) e>, :between<( )>; # => <b ( c d )> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment