>
>
> The definitions of alt-or and alt-and are swapped:
>
> (alt-or false true) and (alt-or true false) both return false, (but (and) 
> is true, and both (alt-and) and (alt-or) are false).
>
> (alt-and true false) and (alt-and false true) both return true.
>

That's some serious C&P errors there indeed, thanks Ben. For completeness 
sake, here's what they should be:

(defn alt-or
  ([] nil)
  ([& args] (reduce (fn [_ s] (if s (reduced s) s)) (alt-or) args)))

(defn alt-and
  ([] true)
  ([& args] (reduce (fn [_ s] (if s s (reduced s))) (alt-and) args)))

(defn alt-every?
  [pred coll]
  (reduce (fn [_ s] (let [t (boolean (pred s))] (if t t (reduced t)))) true 
coll))

(defn alt-some
  [pred coll]
  (reduce (fn [_ s] (let [t (pred s)] (if t (reduced t) t))) nil coll))

 

>  
>
>>
>> Another idea was that this way I could also make core.reducers based 
>> versions. Of course this would mean that sometimes you would evaluate too 
>> much tests, but since this would happen in parallel, in general the result 
>> would return faster. *Am I right in presuming that, or am I overlooking 
>> some very basic argument against them (I'm pretty good at that) ?*
>>
>
> The result wouldn't return faster if the input is an infinite list.
>

I don't think normal *every?* and *some *would do that better, would they ? 
In any case, reducers don't work on lazy sequences, so that shouldn't be a 
problem.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to