On May 30, 12:51 am, Eugen Dück <[email protected]> wrote:
> How often do you do:
> (+ 5)
> or
> (* 3)
>
> ? But you might have used something like
> (apply + coll)
> or
> (reduce + coll)
>
> and under certain circumstances your coll might have had only one
> element.
This is a good line of reasoning. Let's add an example in quantitative
logic, in which corner cases aren't that obvious at first glance:
user=> (every? pos? #{})
true
Clojure follows the mathematical definition here and concludes that
all members of the empty set are indeed positive :-) This is a useful
behaviour since the programmer probably wanted to keep out non-
positive numbers, and the empty set satisfies this restriction. No
need to check for an empty collection beforehand.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en