Re: loop/recur and tail postion

2011-06-15 Thread Kevin Sookocheff
Thanks everyone. Makes perfect sense. -- 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 unsubscri

Re: loop/recur and tail postion

2011-06-15 Thread Ken Wesson
On Wed, Jun 15, 2011 at 10:08 AM, Kevin Sookocheff wrote: > Hi, I'm going through some Scheme code to learn Clojure.  I defined a > function > > rember > > as > > > (defn rember [atom l] >         (loop [a atom lat l] >        (cond >         (empty? lat) `() >         (= (first lat)

Aw: loop/recur and tail postion

2011-06-15 Thread Meikel Brandmeyer
Hi, no, it's not. The cons is in the tail position. Here a working version. (defn rember [a l] (loop [ret [] lat (seq l)] (cond (not lat) ret (= (first lat) a) (recur ret (next lat)) :else (recur (conj ret (first lat)) (next lat) Note, h

Re: loop/recur and tail postion

2011-06-15 Thread Jonas
> Is the call to recur not in tail position here? > > No, because of (cons (first lat) (recur a (rest lat))). You cons (first lat) after you call (recur ...). That is why (recur ...) is not in tail position. -- You received this message because you are subscribed to the Google Groups "Cloju

loop/recur and tail postion

2011-06-15 Thread Kevin Sookocheff
Hi, I'm going through some Scheme code to learn Clojure. I defined a function rember as (defn rember [atom l] (loop [a atom lat l] (cond (empty? lat) `() (= (first lat) a) (rest lat) :else (cons (first lat) (recur a (rest lat))