Node: Function Invocation, Next: , Previous: Control Structure, Up: Control Structure



Function Invocation

As mentioned previously, See Functions, Lpp first class function objects can be generated and manipulated as data and also applied to other data.

funcall fun args Function

This function calls the Lpp function object fun on the args which can be 0 or more arguments of type let. A value of type let that fun returns is returned from the funcall.

apply fun args Function

This function is similar to funcall except that the arguments given to fun is taken from only one argument args which is a list of 0 or more Lpp objects.

Here are some examples that contrast funcall with apply:

     let list1 = list(L("Lost"),  L("World"));
     let fun = L(listConcat);
     funcall(fun, cadr(list1), car(list1)) => WorldLost
     apply(fun, list1) => LostWorld