Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Mathematica, what does @@@ mean?

I've been working through problems on Project Euler, and some of the solutions that other people have posted use a triple-at-sign, i.e. '@@@'. In the help browser for v7, I find an entry for @@ (which says it's the infix version of 'Apply') but none for @@@. What does it mean?

EDIT: Here's an example, which I think I can post without violating the spirit of Project Euler:

bloc[n_, f_][t_] := {f @@@ #, #~Tr~f} & /@ Join @@ Partition[t, {n, n}, 1];
like image 591
Eric Avatar asked Jul 17 '09 02:07

Eric


People also ask

What does [[ 1 ]] mean in Mathematica?

1. Actually, "1" refers to the first element of a list, not the smallest number of a list. Thus a[[1]] is the same as First[a] .

What does := mean in Mathematica?

to clear a value) x == val — test equality or represent a symbolic equation (!= for unequal) lhs := rhs — function etc. definition.

What does ProductLog mean in Mathematica?

ProductLog[z] satisfies the differential equation . For certain special arguments, ProductLog automatically evaluates to exact values. ProductLog can be evaluated to arbitrary numerical precision.

What does $Failed mean in Mathematica?

$Failed. Cell[BoxData["$Failed"], "Input", CellTags -> "$Failed_templates"] is a special symbol returned by certain functions when they cannot do what they were asked to do.


2 Answers

As others have noted, @@@ is, technically, shorthand for Apply with an optional third argument, as is explained deep in the documentation for Apply.

But I like to think of

f @@@ {{a,b}, {c,d}, {e,i}}

as shorthand for

f @@#& /@ {{a,b} {c,d}, {e,i}}

In other words, take a pure function (shorthand: ...#...&) that does an Apply (shorthand: @@) to a list of arguments, and Map (shorthand: /@) that over a list of such lists of arguments. The result is

{f[a,b], f[c,d], f[e,i]}
like image 120
dreeves Avatar answered Sep 20 '22 20:09

dreeves


@@@ is the short form for Apply at level 1.

f @@@ {{a, b, c}, {d, e}}

is equivalent to

Apply[f, {{a, b, c}, {d, e}}, {1}]

Reference: http://reference.wolfram.com/mathematica/ref/Apply.html

You may need to expand the Scope and Level Specification sections.

like image 45
tvanfosson Avatar answered Sep 20 '22 20:09

tvanfosson