Re: noob q: infinite loop recur

2010-08-10 Thread chepprey
To all - THANKS (especially David Sletten) for the excellent responses! Very helpful. -- 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 - plea

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:48 pm, David Sletten wrote: > Notice how Clojure returns two different values here. Other Lisps (such as > Common Lisp) define FIRST/REST of the empty list to both be NIL (i.e., the > empty list itself). So it is common in other Lisps to test for the end of a > list using the

Re: noob q: infinite loop recur

2010-08-10 Thread David Sletten
On Aug 9, 2010, at 11:52 PM, chepprey wrote: > > (defn show [words] > (let [word (first words)] > (do > (println word) > (if (nil? word) > (println "DONE") > (recur (rest wo

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:13 pm, Laurent PETIT wrote: > next is more eager than rest, but in a loop scenario, I generally use next > since we'll test for nil in order to know whether to continue to iterate or > not. I generally use next when I know that I need to realise anyway soon. As Laurent said: th

Re: noob q: infinite loop recur

2010-08-10 Thread Laurent PETIT
Hi, if you recur with "rest", you should use (empty?), if you recur with next, you can use (nil?) next is more eager than rest, but in a loop scenario, I generally use next since we'll test for nil in order to know whether to continue to iterate or not. 2010/8/10 chepprey > Dipping my toes for