On Wed, Jul 22, 2009 at 5:17 PM, mmwaikar wrote:
> So if this is the intended behavior of apply, which function should I
> use in this case? Is there anything in Clojure where I can apply any
> user-defined function to each and every element of a list one-by-one?
Use map:
user=> (map #(* 5 %)
> I would like this move to be applied to each file in the
> list.
If you don't want a sequence back -- probably because you only want
the side-effects -- you should look at doseq.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to th
Thanks Laurent.
I read about map, but I didn't think of using it because "map takes a
source collection coll and a function f, and it returns a new
sequence by invoking f on each element in the coll" and in my
situation, I don't want a new collection back.
So for ex, a have a list of file names
You are searching map.
You should definitely consider reading the datastructures and sequences
pages on clojure.org, or you will be stopped at each step.
Regards,
--
Laurent
2009/7/22 mmwaikar
>
> Hi,
>
> I am getting a little confused in how apply works. I thought that
> (apply f args* args
Hi,
I am getting a little confused in how apply works. I thought that
(apply f args* argseq) means applying f to each of the elements of
argseq one by one (assuming one doesn't pass any args), but it is not
like that. So for ex,
I wrote this: (defn mul5 [arg] (* arg 5))
and wanted to do this: (a