Jeff Mad <[email protected]> writes:

Hi Jeff,

> I was surprised to find out in the REPL that every? returns true if
> you pass in an empty or nil collection.
>
> user=> (every? #(= 77 %) nil)
> true
>
> user=> (every? #(= 77 %) '())
> true

That's correct.  Every item in an empty collection satisfies the
predicate or can you name a counter-example?

Basically,

  (every? pred? coll)

is equivalent to

  (and (pred? (nth coll 0))
       (pred? (nth coll 1))
       (pred? (nth coll 2))
       ...)

The special case of coll being empty is then equivalent to (and) which
is also true.

Bye,
Tassilo

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to