From a8824fac6d139c91352ee9f775a5e37eca4d446c Mon Sep 17 00:00:00 2001
From: Cory Spencer <cspencer@sprocket.org>
Date: Sat, 7 Mar 2009 12:55:10 -0800
Subject: [PATCH] Removed PIR of grep and replaced with P6 version.

---
 build/Makefile.in         |    1 +
 src/builtins/any-list.pir |   34 ----------------------------------
 src/setting/Any-list.pm   |   11 +++++++++++
 3 files changed, 12 insertions(+), 34 deletions(-)
 create mode 100644 src/setting/Any-list.pm

diff --git a/build/Makefile.in b/build/Makefile.in
index c45ef70..f7f13ea 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -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 \
diff --git a/src/builtins/any-list.pir b/src/builtins/any-list.pir
index 93b6a3c..1967fbf 100644
--- a/src/builtins/any-list.pir
+++ b/src/builtins/any-list.pir
@@ -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
diff --git a/src/setting/Any-list.pm b/src/setting/Any-list.pm
new file mode 100644
index 0000000..5d311c5
--- /dev/null
+++ b/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)
+}
-- 
1.6.1.3

