Re: What is @@@?
- To: mathgroup at smc.vnet.net
- Subject: [mg87203] Re: [mg87190] What is @@@?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 4 Apr 2008 02:56:35 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200804031018.FAA26115@smc.vnet.net>
- Reply-to: murray at math.umass.edu
You'll find this in the tutorial "Input Syntax". -- tutorial/InputSyntax.
(You can get to that from the main Documentation Center > Core Language
> Syntax >tutorials. Or if in Mathematica 6.0.2 you open the built-in
Virtual Book, then from Core Language > Appendix:Language Structure >
Input Syntax > Types of Input Syntax.)
On that tutorial page, search for @@@. You'll see that
expr1 @@@ expr2
is a special input form that means
Apply[expr1, expr2, {1}]
So the effect is to replace heads in the parts of expr2 at level {1} by
expr1.
For example:
Remove[f,g,a,b]
Apply[f, g[List[1, 2], List[a, b]], {1}]
g[f[1,2],f[a,b]]
f@@@g[List[1,2],Lis[a,b]] (* same thing *)
g[f[1,2],f[a,b]]
More concrete example:
Apply[Plus, {{1, 2}, {a, b}}, {1}]
{3,a+b}
Plus @@@ {{1, 2}, {a, b}} (* same thing *)
{3,a+b}
Contrast that with, e.g.:
Plus @@ {{1, 2}, {a, b}}
{1+a,2+b}
that is,
Apply[Plus,{{1,2},{a,b}}] (* same thing as preceding *)
{1+a,2+b}
Kevin J. McCann wrote:
> I have seen several references to the command @@@ in this newsgroup, but
> a query of the online Documentation Center just refers me to Apply (@@).
> What does it do and where can I read about it?
>
> Thanks
>
> Kevin
--
Murray Eisenberg murray at 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
- References:
- What is @@@?
- From: "Kevin J. McCann" <Kevin.McCann@umbc.edu>
- What is @@@?