List Append
rascal-0.34.0
Synopsis
Append an element at the end of a list
Types
//
Exp₁ | Exp₂ | Exp₁ + Exp₂ |
---|---|---|
list[T₁] | T₂ | list[lub(T₁,T₂)] |
Description
The operator +
appends an element at the end of a list. The +
is one of those Operators which are overloaded. It can also mean Insert or Concatenation for example.
Examples
rascal>[] + 1;
list[int]: [1]
rascal>[1] + 2;
list[int]: [1,2]
.Benefits:
.Pitfalls:
- If both operands of
+
are a list, then it acts as Concatenation
This is concatenation:
rascal>[1] + [2]
list[int]: [1,2]
To append a list to a list, use extra brackets:
rascal>[1] + [[2]]
list[value]: [
1,
[2]
]