Navigation
Synopsis Concatenate two lists.
Syntax Exp1 + Exp2
Types
Exp1 Exp2 Exp1 + Exp2
list[T1] list[T2] list[lub(T1,T2)]
Description The + operator concatenates the elements of the two lists in order of appearance.

Note that the same operator is overloaded for List/Insert and List/Append.
Examples
rascal>[1, 2, 3] + [4, 5, 6];
list[int]: [1,2,3,4,5,6]
rascal>[] + [1]
list[int]: [1]
rascal>[1] + []
list[int]: [1]
rascal>[1] + [2] + [3]
list[int]: [1,2,3]
And overloaded usage for insert and append looks like:
rascal>1 + []
list[int]: [1]
rascal>[] + 1
list[int]: [1]

Questions
Question [1]. When you compute the concatenation of two lists, the number of elements in the result is always:




Question [2].
The type of [-12, 17, -9, 18] + [18, -2, 12, -3] is

Question [3].
["Jabba the Hut", "Apple"] + ["Boba Fett", "Ailyn Vel"] == 

Question [4].
["Fig"] +  == ["Fig","C","Cayenne","H"]



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.