I have this very trivial function: (defn find-me [n] (loop [coll (iterate inc 20)] (if (= (first coll) n) n (recur (next coll)))))
Let's leave out the problem that the loop may never end. My question is the sequence that's bound to coll in the loop will only generate the next digit in the sequence every time (first coll) is called? How does the evaluation of (next coll) as the next loop parameter affect this? Is it just passing the function (next coll) into the next loop iteration as an argument, and then is that argument being evaluated when (first coll) is called again? Is there another way I should be doing this sort of "look through a sequence of elements until you find an element you are looking for, then return it". I'm just learning Clojure so I'm not sure how to port over a very trivial operation in another language here while working in a Clojure (functional) style. I tried using (take-while) but it returns before I get the element I'm looking for. Thanks for the help. - Jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---