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
(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
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)
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 (=
(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]
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)
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...
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
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
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
10 matches
Mail list logo