| Author |
Comment/Response |
jason
|
09/24/11 10:32am
I don't know if there is a way to define a normal function inside a Module. But you can use a pure function.
To use a pure function of one variable, you put # in place of the variable. For functions of two or more, you use #1, #2, etc. Then you need to put & directly following the pattern you set to indicate it is a function.
I'm also using the shorthand notation f/@x for Map[f,x].
giantfunction[x_] := Module[{a},
a = (# + 1) & /@ x;
#^2 & /@ a];
giantfunction[{1, 2, 3, 4}]
URL: , |
|