On Monday, January 24, 2011 12:59:09 PM UTC, Las wrote:
>
> What did I get wrong?
>
I believe #([% 1]) is equivalent to (fn [a] ([a 1])), not (fn [a] [a 1]) .
Thus, for #([% 1]) , [% 1] is called as a function. Vectors are functions
that take an index and return the vector's value at that inde
Thanks! :)
2011/1/24 Nick Zbinden
> That a problem people find often.
>
> The thing is #(%) not the same as (fn [x] x) its more like (fn [x]
> (x)).
>
> So if you write #([x]) is (fn [x] ([x])) witch throws an error. You
> would have to write #(vec %).
>
> On Jan 24, 1:59 pm, László Török wrote
That a problem people find often.
The thing is #(%) not the same as (fn [x] x) its more like (fn [x]
(x)).
So if you write #([x]) is (fn [x] ([x])) witch throws an error. You
would have to write #(vec %).
On Jan 24, 1:59 pm, László Török wrote:
> Hi,
>
> just a quick one:
>
> (mapcat #([% 1]) [
Hi,
On 24 Jan., 13:59, László Török wrote:
> just a quick one:
>
> (mapcat #([% 1]) [1 3 5])
>
> gives an exception (wrong argument)
>
> (mapcat (fn [a] [a 1]) [1 3 5])
>
> works though...
>
> What did I get wrong?
#([% 1]) is equivalent to (fn [a] ([a 1])). Note the extra parens. You
want #(ve
Hi,
just a quick one:
(mapcat #([% 1]) [1 3 5])
gives an exception (wrong argument)
(mapcat (fn [a] [a 1]) [1 3 5])
works though...
What did I get wrong?
Thx
Las
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email