This is my first question. I'm fairly new to Mathematica and completely new to SE, so I apologize if this question is trivial.
I'm working on a problem that requires a function to be redefined several times and applied to data. My "function generator" (not sure if this is the proper application of this term) looks like this:
makeLine[{m_, b_}] := line = Function[{x, y}, y - m x - b]
The idea being that the program can call line several times and then redefine it and call it again.
I was hopeful that I could do something like this:
Module[{line}, makeLine[{1, 0}]]
to avoid defining line as a global function, but it doesn't work.
?line
Global`line
line = Function[{x\$, y\$}, y\$ - 1 x\$ - 0]
So, is it possible to do this? If not, can someone suggest an alternate construct that does essentially the same thing?
SetAttributes[makeLine, HoldRest]; makeLine[{m_, b_}, line_] := line = Function[{x, y}, y - m x - b]
$\endgroup$ – Daniel Lichtblau Mar 14 '13 at 3:30