Applying functionals

  One of the main types of functionals are functions which allow to call other functions, otherwise, to apply functional argument to its parametres. Such functionals name applying functionals.
  Applying functionals are related universal function Lisp eval. While eval calculates value of the arbitrary expression (form), the applying functional calculates value of call of some function. Interpreter Lisp eval and actually calls applying functional apply at a call evaluation, and apply in turn calls eval at an evaluation of value of other forms.
  Applying functionals give the chance to interpret and reduce data in the program and to apply it in evaluations.

APPLY applies function to the list of arguments

   apply is (in the initial form) function of two arguments from which the first argument represents function which is applied to the units of the list making the second argument of function apply:

  (nil apply obj fn list)
  ≡
  (obj fn 'x1 'x2 … 'xn),

  where the list=(x1 x2 … xn)

>(nil apply 2 '+ '(3))
5
>(nil apply nil 'cons '(that (will wish)))
(that will wish)
>('f set '+)
+
>(nil apply 2 f '(3))
5
>(nil apply nil 'eval '((2 + 3)))
5
>(nil apply nil 'apply '(2 + (3)))
; apply applies itself
5
>(nil apply nil '(lambda (x y) (x + y)) '(2 3))
5

  Usage apply gives the big flexibility in comparison with direct function call: by means of the same function apply it is possible to realise various evaluations depending on functional argument.

FUNCALL calls function with arguments

  The functional funcall on the operation is similar apply, but for called function it accepts arguments not the list, and separately:

  (nil funcall obj fn x1 x2 … xn)
  ≡
  (obj fn x1 x2 … xn)

  Let's give an example:

>(nil funcall 2 '+ 3)
5

   funcall and apply allow to set evaluations (function) by the arbitrary form, for example, as in function call, or the character which value is the functional object. In ordinary function call it is possible to use only the character linked defmethod with lambda-expression. Name interpretation depends on a syntactic position.

>('addition set '+)
+
>(nil funcall 2 addition 3)
5
>(nil funcall 2 ('(+ - * /) first) 3)
5

  Thus there is a possibility to use function name synonyms. On the other hand, the function name can be used as an ordinary variable, for example for storage of other function (a name or lambda-expression), and these two senses (value and definition) will not hinder each other:

>('cons set '+)
+
>(nil funcall 2 cons 3)
5
>(nil cons 2 3)
(2 . 3)

  As the second argument of a functional funcall is calculated by ordinary rules on its place there should be an expression the character or lambda-expression will be which value.