It looks like you're new here. If you want to get involved, click one of these buttons!
function derivative(f,delta) delta=delta or 1e-4 return function(x) return ( f(x + delta ) -f(x))/delta end end ----- It Runs like this ------------ c=derivative(math.sin) print(math.cos(10),c(10)) -->-0.83907152907645-0.83904432662041 Becausefunctionsarefirst-classvaluesinLua,wecanstorethemnoto |
Comments
math.sin
its like defining a function
myfunc = math.sin(x)
and calling
myfunc(100)
which is the same as math.sin(100)
but its putting the entire user defined function .... into "c"
...i knew i should have been a brick layer....
http://artleeapps.com/
Bubble Adventure - Colors