I have a very large number of functions defined in the following manner:
f[1] = Function[{x}, x^2];
f[2] = Function[{x}, x^3];
I would like to make all of these Listable
. Is there any simple way of doing this? I have tried:
Attributes[f[2]] = {Listable};
and
SetAttributes[f[2],Listable];
both of which failed miserably!
Thanks!
AppendTo[f[1], Listable]
? $\endgroup$Listable
, becausePower
operation maintains listability. Moreover, if you give them explicitListable
attribute, you will only make matters worse. Read this. $\endgroup$f[1] = Function[{x}, x^2, Listable]
. Pure functions can have a subset of symbol attributes (includingListable
), and then you specify them as a third optional argument toFunction
. Still, read the link I provided, to not run into nasty performance surprises. Because addingListable
attribute won't make the performance better, but can easily make it worse, so adding it for performance reasons doesn't make much sense, and can be counterproductive. $\endgroup$