Re: noob question about error with tail recursion

2011-11-30 Thread coco
now I'm in a similar trouble...I'm trying resolve the problem 31 from 4clojure ...It says: Write a function which packs consecutive duplicates into sub-lists. [image: test not run] (= (__ [1 1 2 1 1 1 3 3]) '((1 1) (2) (1 1 1) (3 3))) I know than I can use identity and others clojure functions

Re: noob question about error with tail recursion

2011-11-30 Thread Chris Perkins
(recur (rest lista) ...) here: ^^^ lista is always the same thing. You probably meant (recur (rest rst) ...). - Chris -- 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

Re: noob question about error with tail recursion

2011-11-30 Thread carlos mendez
yep..that is an error but (recur (rest rst) I think wouln't work...maybe something like (defn packing [lista] (loop [[fst snd :as all] listamem []tmp '(fst)] (print all is all \n\n) ;;something is wrong...all always is a empty list (if (seq? all) (if (= fst snd)

Re: noob question about error with tail recursion

2011-11-30 Thread coco
yep..that is an error but (recur (rest rst) I think wouln't work...maybe something like (defn packing [lista] (loop [[fst snd :as all] listamem []tmp '(fst)] (print all is all \n\n) ;;something is wrong...all always is a empty list (if (seq? all) (if (=

Re: noob question about error with tail recursion

2011-11-30 Thread Alan Malloy
(seq? ()) is true. You want (seq all), not (seq? all). There may be other problems, but that one jumps out at me. On Nov 30, 1:53 pm, coco clasesparticulares...@gmail.com wrote: yep..that is an error but (recur (rest rst) I think wouln't work...maybe something like (defn packing [lista]  

noob question about error with tail recursion

2011-11-22 Thread coco
Hi..I've a little problem using recur for recursive calling...I'm trying do the clojure koans and the recursive reverse function [1 2 3 4] - '(4 3 2 1) first I try this code: (defn recursive-reverse [coll] (loop [col coll mem '()] (if (empty? coll) mem ((cons (last col) mem)

Re: noob question about error with tail recursion

2011-11-22 Thread Sean Corfield
On Tue, Nov 22, 2011 at 8:49 PM, coco clasesparticulares...@gmail.com wrote:      ((cons (last col) mem)       (recur (butlast col) mem) ...      ((cons (last col) mem)       (recur col mem) In both of these, you have a function call with (cons (last col) mem) as the function...

Re: noob question about error with tail recursion

2011-11-22 Thread coco
thanks for the answer, well, I rewrote the function lik this: (defn recursive-reverse [coll] (loop [col coll mem '()] (if (empty? col) mem (recur (rest col) (cons (first col) mem)) ))) I've a little logic problem but I fix it thanks On Nov 23, 12:54 am, Sean Corfield

Re: noob question about error with tail recursion

2011-11-22 Thread Sean Corfield
On Tue, Nov 22, 2011 at 9:22 PM, coco clasesparticulares...@gmail.com wrote: thanks for the answer, well, I rewrote the function lik this: (defn recursive-reverse [coll]  (loop [col coll mem '()]    (if (empty? col)      mem      (recur (rest col) (cons (first col) mem)) ))) I've a little

Re: noob question about error with tail recursion

2011-11-22 Thread Tassilo Horn
coco clasesparticulares...@gmail.com writes: thanks for the answer, well, I rewrote the function lik this: (defn recursive-reverse [coll] (loop [col coll mem '()] (if (empty? col) mem (recur (rest col) (cons (first col) mem)) ))) I've a little logic problem but I fix