Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
$\begingroup$Compare f /@ g[h[1], h[2], h[3]] and f @@@ g[h[1], h[2], h[3]] to see the difference :) Remember, Map wraps functions around stuff, while Apply replaces the heads of stuff.$\endgroup$
$\begingroup$Well, try it: f @@@ {{1,2},{x,y}} and f /@ {{1,2}, {x,y}}. Is the result the same or different? Remember that it's not necessary to define f to do this (in fact you shouldn't define it to really see what's happening).$\endgroup$
$\begingroup$f /@ list maps a function f onto each element of list, so list is a set of arguments on which f will be evaluated. f @@@ list replaces the Head of each level-1 element in list.$\endgroup$
$\begingroup$You might be interested in this answer by dreeves who points out that we may think of f@@@lst as being a shorthand for f @@ # & /@ lst. That is, we may think of Apply at level one as being equivalent to mapping Apply to each (level one) element of lst. Perhaps this is what you mean? f @@ # & /@ {{1, 2}, {x, y}} == f @@@ {{1, 2}, {x, y}}$\endgroup$
f /@ g[h[1], h[2], h[3]]
andf @@@ g[h[1], h[2], h[3]]
to see the difference :) Remember,Map
wraps functions around stuff, whileApply
replaces the heads of stuff. $\endgroup$f @@@ {{1,2},{x,y}}
andf /@ {{1,2}, {x,y}}
. Is the result the same or different? Remember that it's not necessary to definef
to do this (in fact you shouldn't define it to really see what's happening). $\endgroup$f /@ list
maps a functionf
onto each element oflist
, solist
is a set of arguments on whichf
will be evaluated.f @@@ list
replaces theHead
of each level-1 element inlist
. $\endgroup$f@@@lst
as being a shorthand forf @@ # & /@ lst
. That is, we may think of Apply at level one as being equivalent to mapping Apply to each (level one) element of lst. Perhaps this is what you mean?f @@ # & /@ {{1, 2}, {x, y}} == f @@@ {{1, 2}, {x, y}}
$\endgroup$