MathGroup Archive 2012

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

Search the Archive

Re: new functional operator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125624] Re: new functional operator
  • From: Barrie Stokes <Barrie.Stokes at newcastle.edu.au>
  • Date: Thu, 22 Mar 2012 05:51:29 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jjfd6e$7u7$1@smc.vnet.net> <jjpakk$ov1$1@smc.vnet.net>

Hi Bobby

I agree with your sentiments.  The folk who like {1, 2, 3, 4} // f /@ # & // g /@ # & are those who regret the passing of assembly coding by hand, which opened up programming to the great unwashed.

Of course it can be immeasurably improved by the addition of some more characters, to wit:

{1, 2, 3, 4} // (f /@ # & ) // (g /@ # &)

But, what about my favourite?

Map[ (s \[Function] g[ f[ s ] ]), {1, 2, 3, 4} ]

Or, somewhat less attractive IMHO,

(s \[Function] g[ f[ s ] ]) /@ {1, 2, 3, 4}.

I like (s \[Function] g[ f[ s ] ])  because to me it is intuitive, to use your word. I don't have to recall the way Composition[ ] works, I just have to know what g( f( x ) ) means in mathematics, and the \[Function] arrow is at least more suggestive to me of its meaning/effect than such as // or /@ or @@ or @@@, etc. I can at least suspect that \[Function] means "goes to" or "becomes".

Barrie

PS
I've enjoyed this thread, MathGroup!

>>> On 21/03/2012 at 9:46 pm, in message <201203211046.FAA27118 at smc.vnet.net>,
DrMajorBob <btreat1 at austin.rr.com> wrote:
> 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
>>
>>
>>
> 




  • Prev by Date: Re: new functional operator
  • Next by Date: using Mathematica for solving TSP-like problem with route priorities
  • Previous by thread: Re: new functional operator
  • Next by thread: Re: new functional operator