Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » apply » 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

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:

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

The source of this document is in Macaulay2Doc/functions/apply-doc.m2:77:0.