Higher-order function combinators, homed on the Fn class.
Function combinators as static methods: (Fn compose f g), (Fn flip f), (Fn tap f).
Fn(Fn identity x)Return the given value unchanged.
Parameters:
ANY — Value to returnReturns: ANY — The input value unchanged
(Fn const x)Return a function that always returns x, ignoring its argument.
Parameters:
ANY — Value to captureReturns: CALLABLE — A function that always returns x
(Fn compose f g)Right-to-left composition: (Fn compose f g) applies g then f.
Parameters:
CALLABLE — Outer functionCALLABLE — Inner functionReturns: CALLABLE — Composed function f(g(x))
Examples:
((Fn compose (method-ref Num inc) (method-ref Num inc)) 1) => 3(Fn pipe f g)Left-to-right composition: (Fn pipe f g) applies f then g.
Parameters:
CALLABLE — First functionCALLABLE — Second functionReturns: CALLABLE — Piped function g(f(x))
(Fn curry f x)Partially apply a binary function by fixing its first argument.
Parameters:
CALLABLE — Binary function to partially applyANY — First argument to bindReturns: CALLABLE — Function awaiting one argument
(Fn flip f)Return a function that calls f with its two arguments reversed.
Parameters:
CALLABLE — Binary functionReturns: CALLABLE — Function with reversed argument order
(Fn tap f)Call f on the argument for side effects, then return the argument.
Parameters:
CALLABLE — Side-effect functionReturns: CALLABLE — Function applying f then returning its argument
(Fn default-to d x)Return x if non-nil, otherwise return the default d.
Parameters:
ANY — Default valueANY — Value to checkReturns: ANY — x if non-nil, otherwise d
(Fn until pred f x)Repeatedly apply f to x until pred is satisfied, then return the value.
Parameters:
CALLABLE — Predicate to stop onCALLABLE — Transformation functionANY — Initial valueReturns: ANY — First value satisfying pred
(Fn complement pred)Return a function that negates a predicate.
Parameters:
CALLABLE — Predicate to negateReturns: CALLABLE — Negated predicate
(Fn partial f . bound)Partially apply a function with leading arguments.
Parameters:
CALLABLE — Function to partially applyANY — Bound leading argumentsReturns: CALLABLE — Partially applied function
(Fn juxt . fns)Create a function that applies multiple functions and collects results.
Parameters:
CALLABLE — Functions to apply side by sideReturns: CALLABLE — Juxtaposed function
(Fn both f g)Combine two predicates with AND.
Parameters:
CALLABLE — First predicateCALLABLE — Second predicateReturns: CALLABLE — Combined predicate
(Fn either f g)Combine two predicates with OR.
Parameters:
CALLABLE — First predicateCALLABLE — Second predicateReturns: CALLABLE — Combined predicate
(Fn all-pass preds)Return a predicate that passes when all predicates pass.
Parameters:
LIST — List of predicatesReturns: CALLABLE — Combined predicate
(Fn any-pass preds)Return a predicate that passes when any predicate passes.
Parameters:
LIST — List of predicatesReturns: CALLABLE — Combined predicate