Skip to content

Commit

Permalink
Removed PIR of grep and replaced with P6 version.
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
cspencer authored and moritz committed Mar 7, 2009
1 parent f6cdf9b commit 7559fc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 34 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -106,6 +106,7 @@ BUILTINS_PIR = \
src/builtins/traits.pir \

SETTING = \
src/setting/Any-list.pm \
src/setting/Any-str.pm \
src/setting/Array.pm \
src/setting/Bool.pm \
Expand Down
34 changes: 0 additions & 34 deletions src/builtins/any-list.pir
Expand Up @@ -94,40 +94,6 @@ the size of that file down and to emphasize their generic,
.return(retv)
.end

=item grep(...)

=cut

.namespace []
.sub 'grep' :multi('Sub')
.param pmc test
.param pmc values :slurpy
.tailcall values.'grep'(test)
.end

.namespace ['Any']
.sub 'grep' :method :multi(_, 'Sub')
.param pmc test
.local pmc retv
.local pmc iter
.local pmc block_res
.local pmc block_arg

retv = new 'List'
iter = self.'iterator'()
loop:
unless iter goto done
block_arg = shift iter
block_res = test(block_arg)

unless block_res goto loop
retv.'push'(block_arg)
goto loop

done:
.return(retv)
.end

=item join

=cut
Expand Down
11 changes: 11 additions & 0 deletions src/setting/Any-list.pm
@@ -0,0 +1,11 @@
class Any is also {
our List multi method grep($values: Code $test) {
gather {
take $_ if $test($_) for $values.list;
}
}
}

our List multi grep(Code $test, *@values) {
@values.grep($test)
}

0 comments on commit 7559fc9

Please sign in to comment.