(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 wrote:
> 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] list
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
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
(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 p
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 b
coco 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 it
One minor remark:
On Tue, Nov 22, 2011 at 9:22 PM, coco 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 logic problem but I fi
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 wrot
On Tue, Nov 22, 2011 at 8:49 PM, coco 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...
You're going to need (recur so