129 views

Skip to first unread message

Mar 3, 2012, 6:52:46 AM3/3/12

to

Dear Group and Mathematica staff.

In the functional programming spirit I am missing a postfix notation

for Map[ ].

Du to its clarity I often prefer the sequentiall postfix style

processing of expressions and data:

e.g.

data//F1//F2//F3

but what if our data is a List and the functions we want to perform on

don't have the Listable Attribute ?.

the clumsy solution now is:

data//F1/@#&//F2/@#&//F3/@#&

therefor I suggest a new functional operator, which e.g. could look

like this: ///

such that my favorit expression would appear in this nice and clear

form:

data///F1///F2///F3

In other words the new /// operator should temporarily activate the

Listable Atrribute for the affected function

any comments welcome

Robert

In the functional programming spirit I am missing a postfix notation

for Map[ ].

Du to its clarity I often prefer the sequentiall postfix style

processing of expressions and data:

e.g.

data//F1//F2//F3

but what if our data is a List and the functions we want to perform on

don't have the Listable Attribute ?.

the clumsy solution now is:

data//F1/@#&//F2/@#&//F3/@#&

therefor I suggest a new functional operator, which e.g. could look

like this: ///

such that my favorit expression would appear in this nice and clear

form:

data///F1///F2///F3

In other words the new /// operator should temporarily activate the

Listable Atrribute for the affected function

any comments welcome

Robert

Mar 4, 2012, 4:37:11 AM3/4/12

to

On Saturday, March 3, 2012 8:52:46 PM UTC+9, roby wrote:

> Dear Group and Mathematica staff.

>

> In the functional programming spirit I am missing a postfix notation

> for Map[ ].

How about:
> Dear Group and Mathematica staff.

>

> In the functional programming spirit I am missing a postfix notation

> for Map[ ].

RightVector[a_,f_]:=Map[f, a]

RightVector[a_,more__]:=RightVector[Map[{more}[[1]],a],Sequence@@Drop[{more},1]]

Then:

{1,2,3}\[RightVector](#^2&)\[RightVector]g

yields:

{g[1],g[4],g[9]}

(it looks nicer in a notebook)

Mar 8, 2012, 4:37:18 AM3/8/12

to

On 4 Mrz., 10:37, noqsiaerosp...@gmail.com wrote:

> On Saturday, March 3, 2012 8:52:46 PM UTC+9, roby wrote:

> > Dear Group and Mathematica staff.

>

> > In the functional programming spirit I am missing a postfix notation

> > forMap[ ].
> On Saturday, March 3, 2012 8:52:46 PM UTC+9, roby wrote:

> > Dear Group and Mathematica staff.

>

> > In the functional programming spirit I am missing a postfix notation

>

> How about:

>

> RightVector[a_,f_]:=Map[f, a]

> RightVector[a_,more__]:=RightVector[Map[{more}[[1]],a],Sequence@@Drop[{more },1]]

>

> Then:

>

> {1,2,3}\[RightVector](#^2&)\[RightVector]g

>

> yields:

>

> {g[1],g[4],g[9]}

>

> (it looks nicer in a notebook)

Yes,
> How about:

>

> RightVector[a_,f_]:=Map[f, a]

> RightVector[a_,more__]:=RightVector[Map[{more}[[1]],a],Sequence@@Drop[{more },1]]

>

> Then:

>

> {1,2,3}\[RightVector](#^2&)\[RightVector]g

>

> yields:

>

> {g[1],g[4],g[9]}

>

> (it looks nicer in a notebook)

THIS IS IT

surprisingly easy, surprisingly not yet standard in Mathematica

can even be prettyfied a little bit:

RightVector[a_,f_]:=f/@a

RightVector[a_,more__]:=RightVector[First@{more}/

@a,Sequence@@Rest@{more}]

or we can use LeftTee[ ] which in contrast to RightArrow[ ] already

implements the neccesary left-assocciativitiy such that:

LeftTee[a_, f_] := f /@ a

is all we need.

{1,2,3}\[LeftTee]Sin\[LeftTee]Sqrt

(looks nicer in a notebook)

Robert

Mar 8, 2012, 4:38:51 AM3/8/12

to

> In the functional programming spirit I am missing a postfix notation

> for Map[ ].

I have wanted just such an operation for years. Excellent suggestion.
> for Map[ ].

Mar 8, 2012, 4:40:25 AM3/8/12

to

On 4 Mrz., 10:37, noqsiaerosp...@gmail.com wrote:

RightVector[a_,first_,rest___]:=

If[rest===Null,first/@a,RightVector@@{first/@a,rest}]

Robert

Mar 8, 2012, 4:40:56 AM3/8/12

to

On 4 Mrz., 10:37, noqsiaerosp...@gmail.com wrote:

RightVector[a_, first_, rest___] := If[rest === Null, first /@ a,

RightVector[first /@ a, rest]]

Robert

Mar 9, 2012, 6:11:21 AM3/9/12

to

Ok, next version.

One can look for an prefix operator with no buit in meaning to modify

the function in question such that it acts mapping,

this way we can use the standard // postfix operator and just modify

the behavoir of the function:

\[Del] fn_ := fn /@ # &

{1,2,3,4}//\[Del]f//\[Del]g

Out[5]= {g[f[1]], g[f[2]], g[f[3]], g[f[4]]}

(looks all nice in a Notebook)

Robert

One can look for an prefix operator with no buit in meaning to modify

the function in question such that it acts mapping,

this way we can use the standard // postfix operator and just modify

the behavoir of the function:

\[Del] fn_ := fn /@ # &

{1,2,3,4}//\[Del]f//\[Del]g

Out[5]= {g[f[1]], g[f[2]], g[f[3]], g[f[4]]}

(looks all nice in a Notebook)

Robert

Mar 10, 2012, 6:14:57 AM3/10/12

to

Hi Roby

Very nice also; even prettier is, e.g.,

In[288]:= {1, 2, 3} \[LeftTee] (s \[Function] Sin[ s^(2 Log[ s]) ])

Out[288]= {Sin[1], Sin[2^(2 Log[2])], Sin[3^(2 Log[3])]}

and

In[289]:= {1, 2, 3} \[LeftTee] Sin \[LeftTee] Sqrt \[LeftTee] (s \[Function] Sin[ s^(2 Log[ s ]) ])

Out[289]= {Sin[Sin[1]^(1/2 Log[Sin[1]])],

Sin[Sin[2]^(1/2 Log[Sin[2]])], Sin[Sin[3]^(1/2 Log[Sin[3]])]}

for someone who thinks "#" and "@" are ugly.

I think I like LeftTee more than RightVector, since the former sort of "points" in the direction of application of the pure function.

Maybe LeftVector is another possibility?

Now I just need to devise a mnemonic keyboard shortcut ...

Cheers

Barrie

>>> On 08/03/2012 at 8:36 pm, in message <2012030809...@smc.vnet.net>, roby

Very nice also; even prettier is, e.g.,

In[288]:= {1, 2, 3} \[LeftTee] (s \[Function] Sin[ s^(2 Log[ s]) ])

Out[288]= {Sin[1], Sin[2^(2 Log[2])], Sin[3^(2 Log[3])]}

and

In[289]:= {1, 2, 3} \[LeftTee] Sin \[LeftTee] Sqrt \[LeftTee] (s \[Function] Sin[ s^(2 Log[ s ]) ])

Out[289]= {Sin[Sin[1]^(1/2 Log[Sin[1]])],

Sin[Sin[2]^(1/2 Log[Sin[2]])], Sin[Sin[3]^(1/2 Log[Sin[3]])]}

for someone who thinks "#" and "@" are ugly.

I think I like LeftTee more than RightVector, since the former sort of "points" in the direction of application of the pure function.

Maybe LeftVector is another possibility?

Now I just need to devise a mnemonic keyboard shortcut ...

Cheers

Barrie

>>> On 08/03/2012 at 8:36 pm, in message <2012030809...@smc.vnet.net>, roby

>> On Saturday, March 3, 2012 8:52:46 PM UTC+9, roby wrote:

>> > Dear Group and Mathematica staff.

>>

>> > In the functional programming spirit I am missing a postfix notation

>> > forMap[ ].
>> > Dear Group and Mathematica staff.

>>

>> > In the functional programming spirit I am missing a postfix notation

>>

>> How about:

>>

>> RightVector[a_,f_]:=Map[f, a]

>> RightVector[a_,more__]:=RightVector[Map[{more}[[1]],a],Sequence@@Drop[{more

> },1]]

>>

>> Then:

>>

>> {1,2,3}\[RightVector](#^2&)\[RightVector]g

>>

>> yields:

>>

>> {g[1],g[4],g[9]}

>>

>> (it looks nicer in a notebook)

>

>> How about:

>>

>> RightVector[a_,f_]:=Map[f, a]

>> RightVector[a_,more__]:=RightVector[Map[{more}[[1]],a],Sequence@@Drop[{more

> },1]]

>>

>> Then:

>>

>> {1,2,3}\[RightVector](#^2&)\[RightVector]g

>>

>> yields:

>>

>> {g[1],g[4],g[9]}

>>

>> (it looks nicer in a notebook)

>

Mar 10, 2012, 6:15:28 AM3/10/12

to

Hi Robert

Nice!

But for even greater elegance, IMHO, how about

In[277]:= {a, b, c} \[RightVector] (s \[Function] s^2)

Out[277]= {a^2, b^2, c^2}

Cheers

Barrie

>>> On 08/03/2012 at 8:39 pm, in message <2012030809...@smc.vnet.net>, roby

Nice!

But for even greater elegance, IMHO, how about

In[277]:= {a, b, c} \[RightVector] (s \[Function] s^2)

Out[277]= {a^2, b^2, c^2}

Cheers

Barrie

>>> On 08/03/2012 at 8:39 pm, in message <2012030809...@smc.vnet.net>, roby

Mar 10, 2012, 6:16:30 AM3/10/12

to

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

And, I can set up the definition in init.m so that it is always

available without needing to define it in each notebook where I

would use it.

But it presents another issue. Unless you are writing code for

yourself you will never share with someone else, you will be

making your code much more difficult to understand.

Arguably something like

f/@{1,2,3,4}

is already opaque to a new Mathematica user in terms of

understanding code. But, since this is standard syntax one could

highlight the /@ then use the built-in documentation to

determine what the code is doing. But once you start using

custom notation, this ability is lost. Then, even a well

seasoned user will have great difficulty in determining what the

code does.

And in fact, unless you use such custom notation often, you are

likely to have difficulty with your own code if you need to

review/modify it say a year or two after it was written.

Mar 10, 2012, 6:21:39 AM3/10/12

to

An unfortunate choice of notation, \[Del], for that operator. After all

\[Del] is a universal notation for grad, the gradient operator.

On 3/9/12 6:09 AM, roby wrote:

> Ok, next version.

>

> One can look for an prefix operator with no buit in meaning to modify

> the function in question such that it acts mapping,

> this way we can use the standard // postfix operator and just modify

> the behavoir of the function:

>

>

> \[Del] fn_ := fn /@ #&

>

> {1,2,3,4}//\[Del]f//\[Del]g

>

> Out[5]= {g[f[1]], g[f[2]], g[f[3]], g[f[4]]}

>

> (looks all nice in a Notebook)

>

>

>

> Robert

>

--

Murray Eisenberg mur...@math.umass.edu

Mathematics & Statistics Dept.

Lederle Graduate Research Tower phone 413 549-1020 (H)

University of Massachusetts 413 545-2859 (W)

710 North Pleasant Street fax 413 545-1801

Amherst, MA 01003-9305

\[Del] is a universal notation for grad, the gradient operator.

On 3/9/12 6:09 AM, roby wrote:

> Ok, next version.

>

> One can look for an prefix operator with no buit in meaning to modify

> the function in question such that it acts mapping,

> this way we can use the standard // postfix operator and just modify

> the behavoir of the function:

>

>

> \[Del] fn_ := fn /@ #&

>

> {1,2,3,4}//\[Del]f//\[Del]g

>

> Out[5]= {g[f[1]], g[f[2]], g[f[3]], g[f[4]]}

>

> (looks all nice in a Notebook)

>

>

>

>

--

Murray Eisenberg mur...@math.umass.edu

Mathematics & Statistics Dept.

Lederle Graduate Research Tower phone 413 549-1020 (H)

University of Massachusetts 413 545-2859 (W)

710 North Pleasant Street fax 413 545-1801

Amherst, MA 01003-9305

Mar 13, 2012, 4:01:10 AM3/13/12

to

> An unfortunate choice of notation, \[Del], for that operator. After all

> \[Del] is a universal notation for grad, the gradient operator.

Yes, you are right of course, but \[Del] beside \[PlusMinus] and \
> \[Del] is a universal notation for grad, the gradient operator.

[MinusPlus] are the only prefix operators without predefined meaning/

function in Mathematica.

Every other prefix operator would need Unprotect[ ].

Robert

Mar 14, 2012, 1:34:12 AM3/14/12

to

>

> I don't have any problem agreeing this notation looks nicer than say

>

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

>

> And, I can set up the definition in init.m so that it is always

> available without needing to define it in each notebook where I

> would use it.

>

> But it presents another issue. Unless you are writing code for

> yourself you will never share with someone else, you will be

> making your code much more difficult to understand.

>

Thats why I would prefer /// as postfix-map operator to be implemented
> I don't have any problem agreeing this notation looks nicer than say

>

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

>

> And, I can set up the definition in init.m so that it is always

> available without needing to define it in each notebook where I

> would use it.

>

> But it presents another issue. Unless you are writing code for

> yourself you will never share with someone else, you will be

> making your code much more difficult to understand.

>

by the Mathematica staff.

Any Mathematica staff member listening ?

Robert

Mar 18, 2012, 3:43:46 AM3/18/12

to

On Tuesday, March 13, 2012 11:34:12 PM UTC-6, roby wrote:

> >

> > I don't have any problem agreeing this notation looks nicer than say

> >

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

> >

> > And, I can set up the definition in init.m so that it is always

> > available without needing to define it in each notebook where I

> > would use it.

> >

> > But it presents another issue. Unless you are writing code for

> > yourself you will never share with someone else, you will be

> > making your code much more difficult to understand.

> >

Not any more so than any other specialized function you might define for your problem. You always need to be clear about notation and conventions in Mathematica code. This case is much easier than most, I think.
> >

> > I don't have any problem agreeing this notation looks nicer than say

> >

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

> >

> > And, I can set up the definition in init.m so that it is always

> > available without needing to define it in each notebook where I

> > would use it.

> >

> > But it presents another issue. Unless you are writing code for

> > yourself you will never share with someone else, you will be

> > making your code much more difficult to understand.

> >

>

>

>

> Thats why I would prefer /// as postfix-map operator to be implemented

> by the Mathematica staff.

> Any Mathematica staff member listening ?

Mar 20, 2012, 3:19:23 AM3/20/12

to

> 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 /@ # &

former expression is more or less fogless and would be much easier to

understand.

The latter expression bears a lot of clutter.

Robert

Mar 21, 2012, 6:47:14 AM3/21/12

to

On Tuesday, March 20, 2012 1:19:23 AM UTC-6, roby 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

>

>

> > 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

It isn't clutter in any specific piece of code that's the problem: it's all the cluttered documentation. Many of us appreciated the wonderful Mathematica book when it existed, but Mathematica has too many unnecessary functions these days, so a book is impractical. A vast fog of hypertext isn't as easy to navigate as a book. For functions like the one we're discussing, it's much better to define it only when needed. Then, those trying to understand code that *doesn't* use that function (almost all Mathematica code ever written) won't have to waste time looking past it in the documentation.
> former expression is more or less fogless and would be much easier to

> understand.

> The latter expression bears a lot of clutter.

>

> Robert

Mar 21, 2012, 6:48:46 AM3/21/12

to

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]]}

Bobby

On Tue, 20 Mar 2012 02:18:47 -0500, roby <roby....@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

>

>

DrMaj...@yahoo.com

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]], g[f[2]], g[f[3]], g[f[4]]}

{g[f[1]], g[f[2]], g[f[3]], g[f[4]]}

{g[f[1]], g[f[2]], g[f[3]], g[f[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....@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

>

>

>

--
> former expression is more or less fogless and would be much easier to

> understand.

> The latter expression bears a lot of clutter.

>

> Robert

>

>

>

DrMaj...@yahoo.com

Mar 22, 2012, 6:51:58 AM3/22/12

to

Hi Bobby

Well, if you remeber I was looking for a postfix style.

As such 5 out of your 6 suggestitions disqualify, the 6th one is the

"truly awful" original notation I was trying to replace.

Further I was looking for an operator form so again 3 out of 6

suggestitions disqualify.

Robert

> DrMajor...@yahoo.com

Well, if you remeber I was looking for a postfix style.

As such 5 out of your 6 suggestitions disqualify, the 6th one is the

"truly awful" original notation I was trying to replace.

Further I was looking for an operator form so again 3 out of 6

suggestitions disqualify.

Robert

Mar 22, 2012, 6:54:01 AM3/22/12

to

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 <2012032110...@smc.vnet.net>,

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 <2012032110...@smc.vnet.net>,

DrMajorBob <btr...@austin.rr.com> wrote:

> Here SIX several equivalent expressions from (IMHO) most intuitive or

> readable to least:

>

> Composition[g, f] /@ {1, 2, 3, 4}

>

> 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

>

>

> Bobby

>

> On Tue, 20 Mar 2012 02:18:47 -0500, roby <roby....@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

>>

>>

>

>>> 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 /@ # &

>>

>>

Mar 22, 2012, 6:55:02 AM3/22/12

to

On 3/21/12 at 5:45 AM, noqsiae...@gmail.com (John Doty) wrote:

>It isn't clutter in any specific piece of code that's the problem:

>it's all the cluttered documentation. Many of us appreciated the

>wonderful Mathematica book when it existed, but Mathematica has too

>many unnecessary functions these days,

The problem is defining "unnecessary". A function you seldom or
>It isn't clutter in any specific piece of code that's the problem:

>it's all the cluttered documentation. Many of us appreciated the

>wonderful Mathematica book when it existed, but Mathematica has too

>many unnecessary functions these days,

never use might be one I use extensively. You would see this as

unnecessary function but I would see it as an essential function.

>For functions like the one we're discussing, it's much better to define

>it only when needed. Then, those trying to understand code that

>*doesn't* use that function (almost all Mathematica code ever written)

>won't have to waste time looking past it in the documentation.

should be more understandable. But this rather defeats the point

of having compact notations you want to use often.

Mar 23, 2012, 2:33:25 AM3/23/12

to

Hi Berry,

the original posting topic was about a nice to have postfix operator.

your favorit:

s \[Function] g[ f[ s ] ]

is a realy nice notation for pure functions instead of #& or

Function[ ]

but it does not address the original topic.

please dont hijack my posting

Robert

the original posting topic was about a nice to have postfix operator.

your favorit:

s \[Function] g[ f[ s ] ]

is a realy nice notation for pure functions instead of #& or

Function[ ]

but it does not address the original topic.

please dont hijack my posting

Robert

Mar 24, 2012, 3:05:13 AM3/24/12

to

I'd still have to go with

Composition[g, f] /@ {1, 2, 3, 4}

It's fewer keystrokes and emphasizes that you're composing one function

with another, and it's not hard to the right to left convention we've

ALWAYS used in math.

Bobby

DrMaj...@yahoo.com

Composition[g, f] /@ {1, 2, 3, 4}

with another, and it's not hard to the right to left convention we've

ALWAYS used in math.

Bobby

>> {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....@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

>>>

>>>

>>

>> Bobby

>>

>> On Tue, 20 Mar 2012 02:18:47 -0500, roby <roby....@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

>>>

>>>

>>>

>>

>

--
>>> former expression is more or less fogless and would be much easier to

>>> understand.

>>> The latter expression bears a lot of clutter.

>>>

>>> Robert

>>>

>>>

>>>

>>

>

DrMaj...@yahoo.com

Mar 25, 2012, 1:15:46 AM3/25/12

to

I vote for

g /@ f /@ {1, 2, 3, 4}

It's cleaner.

On Mar 24, 12:05 am, DrMajorBob <btre...@austin.rr.com> wrote:

> I'd still have to go with

>

> Composition[g, f] /@ {1, 2, 3, 4}

>

> It's fewer keystrokes and emphasizes that you're composing one function

> with another, and it's not hard to the right to left convention we've

> ALWAYS used in math.

>

> Bobby

>

> On Wed, 21 Mar 2012 17:53:12 -0500, Barrie Stokes

>

> DrMajor...@yahoo.com

g /@ f /@ {1, 2, 3, 4}

On Mar 24, 12:05 am, DrMajorBob <btre...@austin.rr.com> wrote:

> I'd still have to go with

>

> Composition[g, f] /@ {1, 2, 3, 4}

>

> It's fewer keystrokes and emphasizes that you're composing one function

> with another, and it's not hard to the right to left convention we've

> ALWAYS used in math.

>

> Bobby

>

> On Wed, 21 Mar 2012 17:53:12 -0500, Barrie Stokes

>

> <Barrie.Sto...@newcastle.edu.au> wrote:

>> 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.FAA27...@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

Mar 26, 2012, 2:51:10 AM3/26/12

to

I agree.

If you want to use some of the same characters that denote swearing in comic books (or did when I read comics), g /@ f /@ {1, 2, 3, 4} is pretty clean an unambiguous.

Barrie

>>> On 25/03/2012 at 4:15 pm, in message <2012032505...@smc.vnet.net>, Ray

If you want to use some of the same characters that denote swearing in comic books (or did when I read comics), g /@ f /@ {1, 2, 3, 4} is pretty clean an unambiguous.

Barrie

>>> On 25/03/2012 at 4:15 pm, in message <2012032505...@smc.vnet.net>, Ray

>>>> {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.no...@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

>>>>>

>>>>

>>>> Bobby

>>>>

>>>> On Tue, 20 Mar 2012 02:18:47 -0500, roby <roby.no...@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 /@ # &

>>>>>

>>>>>

Mar 28, 2012, 5:57:09 AM3/28/12

to

Well, here I have an "almost perfect" postfix solution. Enjoy.

In[11]:= "}4,3,2,1{@/soC@/niS@/naT" // StringReverse //

ToExpression

Out[11]= {Tan[Sin[Cos[1]]], Tan[Sin[Cos[2]]], Tan[Sin[Cos[3]]],

Tan[Sin[Cos[4]]]}

Robert

In[11]:= "}4,3,2,1{@/soC@/niS@/naT" // StringReverse //

ToExpression

Out[11]= {Tan[Sin[Cos[1]]], Tan[Sin[Cos[2]]], Tan[Sin[Cos[3]]],

Tan[Sin[Cos[4]]]}

Robert

Jun 3, 2012, 5:00:46 AM6/3/12

to

MakeExpression[RowBox[{l_, UnderscriptBox["//", i_], r_}],

form : StandardForm] :=

MakeExpression[

RowBox[{"Map", "[", RowBox[{r, ",", l, ",", i}], "]"}], form]

Jun 3, 2012, 5:05:53 AM6/3/12

to

Composition, mapping twice... They are all nice, but the original question was clearly of someone that likes the flow of postfix. You do this, then you do that, then you do that and finally you do that. So the typing needs to be in that order.

I'd suggest keeping // as the "postfix application" operator. /// would have been nice since it's similar to //. Most other options won't have the appropriate precedence, so you'll be parenthesising everything.

So, you could do an underscripted // (underscripted by "/@", or by "{}", to have the "map application". For example

MakeExpression[ RowBox[{l_, UnderscriptBox["//", RowBox[{"{", "}"}]], r_}], form : StandardForm] := MakeExpression[RowBox[{r, "/@", l}], form]

Now you use an // underscripted by {} as a map application. If you want to share the code, you can turn it into standard form by selecting the cell, Convert To, and it becomes a regular prefix map

I'd suggest keeping // as the "postfix application" operator. /// would have been nice since it's similar to //. Most other options won't have the appropriate precedence, so you'll be parenthesising everything.

So, you could do an underscripted // (underscripted by "/@", or by "{}", to have the "map application". For example

MakeExpression[ RowBox[{l_, UnderscriptBox["//", RowBox[{"{", "}"}]], r_}], form : StandardForm] := MakeExpression[RowBox[{r, "/@", l}], form]

Now you use an // underscripted by {} as a map application. If you want to share the code, you can turn it into standard form by selecting the cell, Convert To, and it becomes a regular prefix map

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu