RosettaCodeData/Task/Accumulator-factory/Mathematica/accumulator-factory.math
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

8 lines
131 B
Text

accFactory[initial_] :=
Module[{total = initial},
Function[x, total += x]
]
x=accFactory[1];
x[5.0];
accFactory[3];
x[2.3]