ExtendWith
Appends elements to the end of a linear container.
Syntax
-
ExtendWith(X, x)
-
X
is a linear container -
x
is any (compatible) object
-
Description
If X
is any linear container and x
any object that can be present in X
, or a container of such objects, then append(X, x)
returns X
with x
or, preferably, the elements of x
added at the end, so that #append(X, x) = #X + 1
or (preferably) #append(X, x) = #X + #x
.
The difference between append
and ExtendWith
becomes evident if x
is a container itself. In this case, the difference is that append(X, x)
adds the object x
to the end of X
, while ExtendWith(X, x)
attempts to add the contents of x
to the end of X
, possibly adding several (specifically, #x
) new elements to X
.
Examples
v ≔ SequenceVector(10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
ExtendWith(v, 11)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
L ≔ '(1, 2, 3)
1 2 3
ExtendWith(L, '(4, 5))
1 2 3 4 5