.< is an expression macro that composes one or more unary functions in right-to-left (mathematical) order.
Syntax
(.< ⟨fn-expr⟩+)
Semantics
- Requires at least one
⟨fn-expr⟩. (.< f1 f2 ... fn)expands to(fn (x) (nest f1 f2 ... fn x)), which further expands to(fn (x) (f1 (f2 (... (fn x)))))for a fresh parameterx.- When the resulting function is applied to an argument
x,fnis called first onx, andf1is called last. - With a single argument,
(.< f)expands to(fn (x) (f x)). - Because
.<is a macro rather than an ordinary function, it can compose an arbitrary number of stages into a single lambda without allocating intermediate composed closures, and cannot itself be passed unapplied as a higher-order function value.
Examples
(coalton
(map (.< show-as-string
ƒx.(* x x)
ƒx.(+ x 1))
(the (List Integer) [1 2 3 4])))
; => ("4" "9" "16" "25")
Other notes
.<is the point-free counterpart ofnest, and composes functions in the same right-to-left order as the standard library binary functioncompose(and the opposite order of.>).- When you need a first-class binary composition function value
(B -> C) * (A -> B) -> (A -> C), usecomposefrom the standard library.