As indicated in the title I'm looking for the fastest way to transform a[b[c]]
into a[b][c]
, and the natural generalization to an arbitrary chaining of arguments. I'm sure there's got to be a convenient way that I've overlooked.
In my cases a
, b
, and c
can be any expression with any complicated internal structure they like.
As an example, we could have some terrible deeply nested thing like:
bleh =
Nest[f, 10, 10]@
Nest[b, 100, 100]@Nest[c, RandomReal[{}, {1000, 1000}], 1000];
And then we can to convert this into:
blehm =
Nest[f, 10, 10][
Nest[b, 100, 100]][Nest[c, RandomReal[{}, {1000, 1000}], 1000]]
Operate
. $\endgroup$f = Curry[Replace][a_[b_[c_]] :> a[b][c]]
also works, so thata[b[c]] // f
gives the desired result. $\endgroup$a[b[c[d[...]]]]
toa[b][c][d]...
? $\endgroup$a b c
to be any expression you better show some examples, what isa[b[c], d[e, f]]
supposed to be converted to? $\endgroup$