|
|
Re: new functional operator
Posted:
Mar 21, 2012 6:48 AM
|
|
Here SIX several equivalent expressions from (IMHO) most intuitive or readable to least:
Composition[g, f] /@ {1, 2, 3, 4}
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
g /@ f /@ {1, 2, 3, 4}
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
Apply[Composition, {g, f}] /@ {1, 2, 3, 4}
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
g@f@# & /@ {1, 2, 3, 4}
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
Compose[g, f@#] & /@ {1, 2, 3, 4}
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
{1, 2, 3, 4} // f /@ # & // g /@ # &
{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}
The last is truly awful.
Bobby
On Tue, 20 Mar 2012 02:18:47 -0500, roby <roby.nowak@gmail.com> wrote:
>> That creates a information fog that makes *all* Mathematica code harder >> to understand, and Mathematica much harder to learn than it used to be. > > {1, 2, 3, 4} /// f///g > > >> {1, 2, 3, 4} // f /@ # & // g /@ # & > > sorry but I absolutly can't agree with your opinion in this case, the > former expression is more or less fogless and would be much easier to > understand. > The latter expression bears a lot of clutter. > > Robert > > >
-- DrMajorBob@yahoo.com
|
|