Macaulay2 » Documentation
Packages » Macaulay2Doc :: apply(BasicList,Function)
next | previous | forward | backward | up | index | toc

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

Synopsis

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

See also

Ways to use this method: