Skip to content

Instantly share code, notes, and snippets.

@uasi
Created January 26, 2010 18:41
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 uasi/287089 to your computer and use it in GitHub Desktop.
Save uasi/287089 to your computer and use it in GitHub Desktop.
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