MergeLists

List command

Syntax

Moves every element of one list into another. The source list ends up empty.

MergeLists(<source>(), <destination>() [, <where>])

Parts

<source>The list the elements come from, with its parentheses. It is empty afterwards and has no current element.
<destination>The list that receives the elements, with its parentheses.
<where>Optional. #AK_LIST_LAST (the default) adds at the end, #AK_LIST_FIRST at the start, #AK_LIST_BEFORE or #AK_LIST_AFTER before or after the current element of the destination.

Good to know

  • Returns nothing: write it on its own line.
  • The elements are moved, not copied. Use CopyList() to keep the source.
  • The destination keeps the same current element.
  • The program stops when both arguments are the same list, when the types differ, or when #AK_LIST_BEFORE or #AK_LIST_AFTER is used and the destination has no current element.

Example

NewList a.integer()NewList b.integer()FOR k = 1 TO 2  AddElement(a())  a() = k  AddElement(b())  b() = k * 10NEXTFirstElement(b())MergeLists(a(), b(), #AK_LIST_AFTER)Console(Str(ListSize(a())))   ' 0FOREACH b()  Console(Str(b()))   ' 10, 1, 2, 20NEXT
In the manual : Arrays, lists and maps