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

apply(BasicList,BasicList,Function) -- apply a function to pairs of elements, one from each list

Synopsis

Description

The result will have the same class as the class of L1 and L2.
i1 : apply({1,2,3}, {100,200,300}, (i,j) -> i+j)

o1 = {101, 202, 303}

o1 : List
i2 : apply([1,2,3], [100,200,300], (i,j) -> i+j)

o2 = [101, 202, 303]

o2 : Array
i3 : apply((1,2,3), (100,200,300), (i,j) -> i+j)

o3 = (101, 202, 303)

o3 : Sequence
The exception is that for strings, the result will be a sequence.
i4 : apply("foo", "bar", concatenate)

o4 = (fb, oa, or)

o4 : Sequence

Ways to use this method: