For example, write a function add:
add[3] return 3
add[4] return 7
add[10] return 17
|
For example, write a function add[3] return 3 add[4] return 7 add[10] return 17 |
||||
|
|
|
|
|||
yes! unfortunately, I've earned some reputation now, and I can no longer take over the world. – yohbs Jan 31 at 23:07 |
|||
Why not Unique instead of Module to generate the counter storage? While it works, I'm not sure it's a good idea to rely on leaking Module variables this way. But I bring it up because I'd be glad to understand why it might be relied on. – Joel Klein Feb 1 at 0:00 |
|||
@JoelKlein I believe you could use Unique["x", Temporary] to get similar behavior to the Module but you will still need With to get it into the parts of the code you want so you're "reinventing the wheel" as I see it. I don't see this as "leaking" variables but simply using Module efficiently. Admittedly I'm not the best at exhaustive analysis of programming constructs; if you're interested you should ask Leonid. – Mr.Wizard♦ Feb 1 at 2:20 |