Composition
is sometimes useful for clarity of a code. For the same purpose I try to Apply(@@)
functions as often as it is possible.
My question is how to combine Composition
with Apply
, or, to be more precise, is there any simpler way than one I'm going to show (there is no Composition
:)):
Fold[#2@@#1&, arg, {f1, f2,...}]
alternatively:
Fold[Apply[#2,#1]&, arg, {f1, f2,...}]
So for example:
Fold[#2 @@ #1 &, {1, 2}, {{##} &, {#2, #1} &, {#1, 0, #2} &}]
{2, 0, 1}
Fold[]
, so I'm not posting this as an answer:(Composition @@ Function[f, Apply[f, #] &] /@ {{#1, 0, #2} &, {#2, #1} &, {##1} &})[{1, 2}]
. $\endgroup$Composition[f1,f2..., Method->k][__]
wherek
can beApply, Map, MapIndexed
etc. $\endgroup$Composition[Apply @@ # &, Reverse, List]
. $\endgroup$