In Mathematica, what does @@@ mean?

社会主义新天地 提交于 2020-02-10 01:39:45

问题


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

回答1:


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



回答2:


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




回答3:


f @@@ expr is equivalent to Apply[f, expr, {1}].

documents.wolfram.com



来源:https://stackoverflow.com/questions/1141166/in-mathematica-what-does-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!