inc takes number as an argument, not a seq. The function that you are
probably looking for is map:
(map inc [1 2 3 4])
--
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
On Sun Sep 25 06:38 2011, Vincent wrote:
> I cannot understand why this does'nt work
> (apply inc [1 2 3 4]) ; apply inc to each vector element
From the documentation:
clojure.core/apply
([f args* argseq])
Applies fn f to the argument list formed by prepending args to argseq.
This means
> why inc can't take each element and incr it giving the result ... 2 3 4 5
> thanks in advance
apply works as if you were calling the function with the elements of
the vector. In other words:
(apply inc [1 2 3 4 5) ==is like saying===> (inc 1 2 3 4 5)
Which is not what you want.
However, t
I cannot understand why this does'nt work
(apply inc [1 2 3 4]) ; apply inc to each vector element
while this works
(apply println [1 2 3 4]) ;; takes each element and prints it
why inc can't take each element and incr it giving the result ... 2 3 4 5
thanks in advance
vincent
--
You r