append
-- add elements to a
listappend(
l, object)
adds object
to the list l
.
append(l, object1, object2, ...)
l |
- | a list |
object1, object2, ... |
- | arbitrary MuPAD objects |
the extended list.
l
append(
l, object1, object2, ...)
appends
object1
, object2
, etc. to the list
l
and returns the new list
as the result.append(
l)
is legal and returns
l
.append(
l, object1, object2, ...)
is
equivalent to both [op(l), object1, object2, ...]
and
l.[object1, object2, ...]
. However, append
is
more efficient.append
always returns a new object. The
first argument remains unchanged. See example 2.append
is a function of the system kernel.The function append
adds new elements to
the end of a list:
>> append([a, b], c, d)
[a, b, c, d]
If no new elements are given, the first argument is returned unmodified:
>> l := [a, b]: append(l)
[a, b]
The first argument may be an empty list:
>> append([], c)
[c]
The function append
always returns a new
object. The first argument remains unchanged:
>> l := [a, b]: append(l, c, d), l
[a, b, c, d], [a, b]
Users can overload
append
for their own domains.
For illustration, we create a new domain T
and supply it
with an "
append" slot, which simply adds the remaining
arguments to the internal operands of its first argument:
>> T := newDomain("T"): T::append := x -> new(T, extop(x), args(2..args(0))):
If we now call append
with an object of
domain type T
, the slot routine T::append
is
invoked:
>> e := new(T, 1, 2): append(e, 3)
new(T, 1, 2, 3)