Clojure, a Lisp type of language, has a so called Thread
macro which converts nested function calls into a linear flow of function calls, thus improving readability, testability and inviting pure functional (reactive) programming.
I suppose that an equivalent in Mathematica would work as follows:
Let
listany = {{1, 2}, {3, 4}};
listopr = {Flatten, Map[f], Map[g]};
and assume that t
is the equivalent of Clojure's ->
( thread macro ), and $f$ and $g$ are functions transforming elements of listany
. Then:
t[listany, listopr]
would be translated to
Map[g]@Map[f]@Flatten@listany
Similarly,
t[5, {f, g, h}]
would be translated to
h@g@f@5
Do you have a suggestion on how to implement t
in Mathematica?
Composition
orRightComposition
$\endgroup$Composition
: tryx = 1; SymbolName@Unevaluated@x
vsComposition[SymbolName, Unevaluated][x]
more in closely related: 54762 $\endgroup$