MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: new functional operator


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 at 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 at yahoo.com



  • Prev by Date: Re: new functional operator
  • Next by Date: Re: Problems reading text files with embedded delimiters
  • Previous by thread: Re: new functional operator
  • Next by thread: Re: new functional operator