Hi John,
The use of "applies" in the documentation for Map
is misleading. Map
does not Apply
. A better description might be "Map evaluates f for each element of the first level in expr". The following examples should help you understand the difference.
ClearAll@f;
list = {266138, 106.75, 73.533, -85.006, -0.00230909, -0.000852509, 0.00228309, 0.00335725};
(* Head of list is List *)
list // Head
(* List *)
(* Head of f applied to list is f *)
f @@ list // Head
(* f *)
(* f applied to list passes each element of list as an argument to f *)
f @@ list
(* f[266138, 106.75, 73.533, -85.006, -0.00230909, -0.000852509, 0.00228309, 0.00335725] *)
(* f mapped over list *)
f /@ list
(* {f[266138], f[106.75], f[73.533], f[-85.006], f[-0.00230909], f[-0.000852509], f[0.00228309], f[0.00335725]} *)
(* Define f that returns a list of the second and fourth arguments passed to it *)
f = {#2, #4} &
(* Apply f to list *)
f @@ list
(* {106.75, -85.006} *)
(* Since f expects 4 arguments Map fails because only one argument is passed *)
f /@ list
(* "Slot number 2 in {#2,#4}& cannot be filled from ({#2,#4}&)[266138]" *)
(* This also fails since a single argument is passed to f *)
f[list]
(* "Slot number 2 in {#2,#4}& cannot be filled from
({#2,#4}&)[{266138,106.75,73.533,-85.006,-0.00230909,-0.000852509,0.
00228309,0.00335725}]" *)
(* To make it work, change the Head of list to Sequence *)
f[Sequence @@ list]
(* {106.75, -85.006} *)