Higher Order FunctionsΒΆ

Shen supports higher-order functions. In all ports of Shen running under variants of Lisp, the above will work.

(0-) (define foldl
F Z [] -> Z
F Z [X | Xs] -> (foldl F (F Z X) Xs))
foldl
(1-) (foldl + 0 [1 2 3])
6

(2+) (foldl (function +) 0 [1 2 3])
6

Under non-Lisp platforms, where Lisp symbols are not supported, it is wise to use ‘function’ to indicate that a symbol is being used as an argument to denote a function

Further Reading