Student Support Forum: 'Lists as arguments of functions (?obvious?)' topicStudent Support Forum > General > "Lists as arguments of functions (?obvious?)"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Forum Moderator email me 10/27/98 09:13am > > Is it possible to apply a list of elements as arguments of a function without going through ''for'' and ''table''? > > eg: something that transforms {a,b,c} in f[a,b,c] > > If not is it possible to make this as a ''suffix'' form? (eg: {a,b,c} f ) > > If possible reply to mail address. > > Thanks > ===== It is not exactly clear what you are wanting to do. I will guess that you have some function that evaluates for 1, 2, and 3 as f[1], f[2], and f[3] respectively, but that f[{1,2,3}] returns at least partially unevaluated. If the goal is to apply f to 1, 2, and 3, that can be done in at least two ways: - Use Map In[1]:= Map [f, {1,2,3}] Out[1]= {f[1],f[2],f[3]} If applying f to a List is common you can use the Listable Attribute In[2]:= SetAttributes[f, Listable] Now f is automatically applied to each element of the list: In[3]:= f[{1,2,3}] Out[3]= {f[1],f[2],f[3]} Tom Zeller Forum Moderator. URL: ,

 Subject (listing for 'Lists as arguments of functions (?obvious?)') Author Date Posted Lists as arguments of functions (?obvious?) Pedro Alves 10/26/98 4:32pm Re: Lists as arguments of functions (?obvious?) Forum Modera... 10/27/98 09:13am Re: Lists as arguments of functions (?obvious?) Pedro Alves 10/27/98 12:07pm Re: Lists as arguments of functions (?obvious?) Forum Modera... 10/27/98 12:18pm Re: Lists as arguments of functions (?obvious?) Aaron Honecker 11/13/98 10:18am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic