GENERATE/PREV.gifGENERATE/NEXT.gif

Function Variables

When you define a function, two events occur:

This lets you not only call the function, but also pass the actual function to a variable, and store it in an array, for example, just by using that variable:

-- some 3D surface functions

fn saddle x y = sin x * sin y

fn sombrero x y = cos (x^2 + y^2) / (1 + (x^2 + y^2))

print (saddle 1 1)      -- try one out

surface_functions[1] = saddle      -- store them in an array

surface_functions[2] = sombrero

z = (surface_functions[i]) 10 10      -- call one of them from within the array

build_math_mesh sombrero      -- pass one in to a higher-order function