(procedure arg1 arg2 ... argn )
All elements of the application, including the procedure itself, are evaluated.
(define foo +)
(foo 3 4) ⇒ 7
Thus a procedure can be given to another
procedure as an argument (as data), and then
applied to other data (as a program):
(define arithmetic
(lambda (operate arg1 arg2)
(operate arg1 arg2)))
Now any of the following will work:
(arithmetic + 3 4)
(arithmetic * 3 4)
(arithmetic remainder 30 4)
(arithmetic / 45 17)
(arithmetic expt 3 4)
Q: Will only arithmetic procedures work?
A: Any procedure taking two arguments will work:
(arithmetic stack (filled-triangle -1 -1 0 1 1 -1)
(filled-triangle -1 -1 0 1 1 -1))