title: Need to create a Lua function dynamically
body: <p>I am trying to create a Lua function "on the fly", from within another function. The new Lua function, to be called "fx", should operate on a scalar variable -- say, x -- and return f_x(x), where f_x(x) could be something such as "x+1" or "x^2". Importantly, the function name "fx" is given (as it will be used, with this name, from within other functions), but its properties -- specifically, whether it returns "x+1" or "x^2" -- should be modifiable dynamically. </p>
  
  <p>Suppose that "x" is the scalar-valued input variable and that "y" is a string that contains an instruction, such as "x+1" or "x^2", that "fx" is supposed to impose on "x". I've naively tried</p>
  
  <pre><code>function make_func (x,y)
     return ( function fx(x) return y end )
  end
  </code></pre>
  
  <p>but that doesn't work.</p>
  
  <p>Any help and guidance will be greatly appreciated!</p>