Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8941

Re: new functional operator

From Barrie Stokes <Barrie.Stokes@newcastle.edu.au>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: new functional operator
Date 2012-03-10 11:14 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jjfd3h$7so$1@smc.vnet.net> (permalink)
References <jit0me$e32$1@smc.vnet.net> <jivd47$n7j$1@smc.vnet.net>

Show all headers | View raw


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 <201203080936.EAA14139@smc.vnet.net>, roby
<roby.nowak@gmail.com> wrote:
> 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[ ].
>>
>> 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,
> 
> 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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

new functional operator roby <roby.nowak@gmail.com> - 2012-03-03 11:52 +0000
  Re: new functional operator noqsiaerospace@gmail.com - 2012-03-04 09:37 +0000
    Re: new functional operator roby <roby.nowak@gmail.com> - 2012-03-08 09:37 +0000
    Re: new functional operator roby <roby.nowak@gmail.com> - 2012-03-08 09:40 +0000
    Re: new functional operator roby <roby.nowak@gmail.com> - 2012-03-08 09:40 +0000
      Re: new functional operator roby <roby.nowak@gmail.com> - 2012-03-09 11:11 +0000
      Re: new functional operator Murray Eisenberg <murray@math.umass.edu> - 2012-03-10 11:21 +0000
    Re: new functional operator Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2012-03-10 11:14 +0000
    Re: new functional operator Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2012-03-10 11:15 +0000
    Re: new functional operator roby <roby.nowak@gmail.com> - 2012-03-13 08:01 +0000
  Re: new functional operator "branton.campbell" <branton.campbell@gmail.com> - 2012-03-08 09:38 +0000

csiph-web