you can always make your own with a little macro but if you just started
learning today you may want to stick with some...
I, like you, wanted a version that returns true or false a couple of
months ago.. here it is:
(defmacro in?
"Returns true if colle contains elm, false otherwise."
[colle elm]
`(if (some #{~elm} ~colle) true false))
Hope that helps...notice this is a macro not a function - the call to
in? will expand at compile time into the body of the macro...in other
words you've just created some new syntax!
Jim
On 14/06/12 16:31, Jacobo Polavieja wrote:
Hi!
I've just started learning Clojure today. I've started reading
"Clojure - Functional Programming for the JVM"
(http://java.ociweb.com/mark/clojure/article.html
<http://java.ociweb.com/mark/clojure/article.html#Collections>).
Anyway, on the collections part
(http://java.ociweb.com/mark/clojure/article.html#Collections) it
called my attention that 'some' returns "nil" instead of "false". The
examples given (being stooges a vector of Strings) are:
(not-every? #(instance? String %) stooges) ; -> false
(some #(instance? Number %) stooges) ; -> nil
Is there a reason why (some) doesn't return false also? I've read
through the doc but as I supposed, there's no explanation about the
reasoning behind it.
Thanks!
--
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