Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Shorthand for MapThread

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95043] Re: [mg95015] Shorthand for MapThread
  • From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
  • Date: Sun, 4 Jan 2009 07:32:49 -0500 (EST)
  • References: <200901031054.FAA02709@smc.vnet.net>

Dear Martin:

First: you can write any two-arguments command in infix notation using
arg1~command~arg2

For example, evaluate:

a~foo~b

And you will obtain foo[a,b]

Therefore, you can evaluate:

f[#1, #2] & ~MapThread~ {{a, b, c}, {d, e, f}}

And you will obtain the same result as MapThread[f[#1, #2] &,{{a, b, c}, =
{d,
e, f}}]

Second: In order to make it really convenient, you can evaluate at the
beginning of your document:

mt=MapThread

After the evaluation above, every time you write mt Mathematica will =
replace
it with MapThread, therefore you will be able to write:

f[#1, #2] & ~mt~ {{a, b, c}, {d, e, f}}

which might be short enough and fast enough for your purposes. On the =
other
hand, something like /@@ might be too complex to implement, because
Mathematica separates /@ from @ even before trying the evaluation.

Hope that helps.
Jose
Mexico



-----Mensaje original-----
De: Schettler, Martin [mailto:MSchettler at scitor.com]
Enviado el: S=E1bado, 03 de Enero de 2009 04:55
Para: mathgroup at smc.vnet.net
Asunto: [mg95015] Shorthand for MapThread

All -



I frequently use Map and MapThread, and find Map's shorthand:



f /@ {a,b,c}



to be very convenient.



As far as I can tell, MapThread has no corresponding "infix" notation.
Can anyone tell me if it's possible (and if so, how) to make my own?
E.g.



f[#1,#2]& /@@ {{a,b,c},{d,e,f}}





Thanks!
Marty





  • Prev by Date: Re: Fourier Transform Graph Coordinates
  • Next by Date: Re: Fourier Transform Graph Coordinates
  • Previous by thread: Shorthand for MapThread
  • Next by thread: Re: Shorthand for MapThread