Quick actions

cmd+k|ctrl+k

Navigation

Languages

my grep

Snippet info

Language

Raku

Visibility

public

Author

fernando-correa

Created

2025-06-11T18:39:53.119219Z

Updated

2025-06-11T18:39:53.119219Z

sub my-grep(@list, &block) {
    gather {
        for @list.batch: &block.count  -> @part {
            my Bool() @resps = block |@part;
            for @resps.kv -> $i, $b {
                take @part[$i] if $b
            }
        }
    }
}

say (^6).&my-grep: -> $a      { $a %% 2 }
say (^6).&my-grep: -> $a, $b  { $a %% 2, $b >= 3 }
say (^7).&my-grep: -> $a, $b? { !$b.defined, $b.defined }
say (^12).&my-grep: -> $a, $b { $b %% 3 }
say <a b c d>.kv.&my-grep: -> $i, $l { $i %% 2 }
say <a b c d>.kv.&my-grep: -> $i, $l { False, $i %% 2 }
INFO