Here is code from core.clj.
The question is when to use when or if.
(defn take
"Returns a lazy seq of the first n items in coll, or all items if
there are fewer than n."
[n coll]
(when (and (pos? n) (seq coll))
(lazy-cons (first coll) (when (> n 1) (take (dec n) (rest
coll))))))
(defn drop
"Returns a lazy seq of all but the first n items in coll."
[n coll]
(if (and (pos? n) (seq coll))
(recur (dec n) (rest coll))
(seq coll)))
-sun
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---