Macaulay2 » Documentation
Packages » Macaulay2Doc :: join
next | previous | forward | backward | up | index | toc

join -- join lists, sequences, and iterable objects

Synopsis

Description

join(A, B, ...) joins the elements of the lists or sequences A, B, ... into a single list or sequence. The inputs may belong to different classes; the class of the result will match the class of the first argument passed to join.

i1 : join( {1,2,3}, (4,5,6), (7,8,9) )

o1 = {1, 2, 3, 4, 5, 6, 7, 8, 9}

o1 : List
i2 : join( (1,2,3), {4,5,6}, {7}, (8,9,10) )

o2 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

o2 : Sequence

The operator | is a convenient shorthand for joining two inputs of the same class.

i3 : {1,2,3} | {4,5,6}

o3 = {1, 2, 3, 4, 5, 6}

o3 : List
i4 : (1,2,3) | (4,5,6)

o4 = (1, 2, 3, 4, 5, 6)

o4 : Sequence

If the first argument is a list or sequence and any later arguments are instances of a class with the iterator method installed, then these instances are converted to sequences and are then joined.

i5 : join({1, 2, 3}, iterator {4, 5, 6})

o5 = {1, 2, 3, 4, 5, 6}

o5 : List

If the first argument is not a list or sequence, then an Iterator object is returned that iterates through each argument sequentially, provided that each argument is an iterable object.

i6 : join(iterator {1, 2, 3}, {4, 5, 6})

o6 = iterator (iterator {1, 2, 3}, {4, 5, 6})

o6 : Iterator
i7 : toList oo

o7 = {1, 2, 3, 4, 5, 6}

o7 : List

See also

For the programmer

The object join is a compiled function.