Function COMPOSE
Syntax:
compose &rest functions => composite-function
Arguments and Values:
functions---a list of designators for functions.
composite-function---a function created by composing functions.
Description:
compose returns a function which is created by composing functions right-associatively.
Examples:
Reference implementation:
This implementation is fairly straightforward, but very inefficient. In my benchmarks, I found it to be orders of magnitude slower than writing out an equivalent lambda function. However, a compiler macro speeds up some common cases immensely:
This compiler macro shouldn't be considered part of the reference implementation, but it may be useful anyway. I, Peter Scott, place this code in the public domain.
This version allows composition of functions with multiple arguments and return values.
Alexandria contains this function. (likely nonexhaustive)