在 Mathematica 中,@@@ 是什么意思? [英] In Mathematica, what does @@@ mean?
问题描述
我一直在解决 Project Euler 上的问题,其他人发布的一些解决方案使用了三重符号,即@@@".在 v7 的帮助浏览器中,我找到了 @@ 的条目(表示它是Apply"的中缀版本),但没有找到 @@@.什么意思?
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?
这是一个例子,我想我可以在不违反 Project Euler 精神的情况下发布它:
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];
推荐答案
正如其他人所指出的,@@@
在技术上是 Apply
的简写,带有可选的第三个参数,正如 Apply
文档.
As others have noted, @@@
is, technically, shorthand for Apply
with an optional third argument, as is explained deep in the documentation for Apply
.
但我喜欢想
f @@@ {{a,b}, {c,d}, {e,i}}
作为
f @@#& /@ {{a,b} {c,d}, {e,i}}
换句话说,采用一个纯函数(简写:...#...&
)执行 Apply
(简写:@@
) 到参数列表,以及 Map
(简写:/@
)覆盖这些参数列表.结果是
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]}
这篇关于在 Mathematica 中,@@@ 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!