W.Ch Lin wrote:
> Does J have filter function like clojure's ?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

I definitely want to hear what the J crowd says, but just to be sure, in 
Clojure you could say

(filter #(zero? (rem % 2)) (range 1 11))
 > 2 4 6 8 10

To pull out the even numbers. So filter takes a predicate and a 
collection basically. I was thinking
in J I'd to something like

,.((|~ & 2) 1 + i. 10) ;, 1 + i.10
+--------------------+
|1 0 1 0 1 0 1 0 1 0 |
+--------------------+
|1 2 3 4 5 6 7 8 9 10|
+--------------------+

Where as you can see all even values get a 0 return from (|~ & 2), but 
that leaves 2 questions

1) Is that how you would do it with J at all?
2) Disregarding 1, how would you pick those 0 values out from the 
original list 1 + i.10 ?

Thanks
Lau




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to