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 (with their full paths), I just want to move each and every file from a source directory to a destn. directory, in which case, if I have a move function, which moves a single file, I would like this move to be applied to each file in the list. Is map still the best function for such a task? Again, the function to be applied to each element returns void, instead of my earlier example. Regards, Manoj. On Jul 22, 5:24 pm, Laurent PETIT <[email protected]> wrote: > 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 <[email protected]> > > > > > 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: (apply mul5 1 2 3 [4 5]) > > > thinking that I'll get a list back where each element of the original > > list is multiplied by 5, but I get IllegalArgumentException: Wrong > > number of args passed to: mul5. > > > 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? > > > Thanks for the replies. > > > Regards, > > Manoj. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
