Welcome! Please see the About page for a little more info on how this works.

0 votes
in Sequences by

how about this version of some?

 (defn some [pred coll]
  (loop [s (seq coll)]
    (when s
      (or (pred (first s)) (recur (next s))))))

1 Answer

+1 vote
by
by
i was not aware of that :-)

i did some performance tests as well, but i find that somewhat tricky, since there are many factors that have to be considered when going from clojure(script) to the bare metal.

i guess my main point is that regardless of the performance, to me at least, the 'logic' of the current version of some is just not right :-).... one could from a logical point of view use rest instead of next... but on newer clojure versions, for some reasons, that did not perform nearly as well as i would have hoped ( ... in my benchmarks at least,... so that does not have to mean very much... :-))

so in any case, i thought this version did fix the 'logical / imperative' problem of some, while also being reasonably clear and easy on the eyes, and so i was kind of hoping i would perhaps be able to make a contribution ( no matter how small ) to clojure itself. :-)

so now seeing, that somebody else has already thought about rewriting some ( in a more sophisticated way than i ever have... :-)) is kind of cool ( i really like the idea! ) but at the same time it is also kind of a bummer :-)

so,  i guess, i just wanted to say that clojure is really great and keep up the good work!
...