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]? – Carl Woll May 03 '17 at 23:13Listable, becausePoweroperation maintains listability. Moreover, if you give them explicitListableattribute, you will only make matters worse. Read this. – Leonid Shifrin May 03 '17 at 23:14f[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 addingListableattribute 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. – Leonid Shifrin May 03 '17 at 23:20