You are using it incorrectly. Separate returns a vector of things that match, and a vector of things that don't match. Every time you call the function it matches against a different random number. Take a look at rand-elt in clojure.contrib.seq-utils.

Maybe the docstring for separate should say that fn should be side- effect-free...

Stu

ok, the following works as expected.

user> (separate (fn [n]
                  (= n 2))
                '(1 2 3 4 5))
[(2) (1 3 4 5)]


now, I want to randomly select a number from '(1 2 3 4 5), I change
the function to the following, and the result is NOT expected.

user> (separate (fn [n]
                  (= n (inc (int (rand 5)))))
                '(1 2 3 4 5))
[() (2 3 4)]


Is it a bug in the separate function or do I use it incorrectly?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to