apply(BasicList,Function) -- apply a function to each element of a list

Synopsis

• Function: apply
• Usage:
apply(L,f)
• Inputs:
• L, or
• f, , with one argument
• Outputs:
• , obtained by applying f to each element of L

Description

The result will have the same class as L.
 i1 : apply({1,3,5,7}, i -> i^2) o1 = {1, 9, 25, 49} o1 : List i2 : apply([1,3,5,7], i -> i^2) o2 = [1, 9, 25, 49] o2 : Array i3 : apply((1,3,5,7), i -> i^2) o3 = (1, 9, 25, 49) o3 : Sequence
The exception is that for strings, the result will be a sequence.
 i4 : apply("foo", identity) o4 = (f, o, o) o4 : Sequence