Skip to main content

List Splice

rascal-0.34.0

Synopsis

Splice the elements of a list in an enclosing list.

Types

//

ExpExp₁Expₙ[Exp₁, ..., Exp, ..., Expₙ]
TT₁Tₙlist[lub(T₁, ..., T, ...,Tₙ)]

Description

The operator * splices the elements of a list in an enclosing list.

Examples

Consider the following list in which the list [10, 20, 30] occurs as list element. It has as type list[value]:

rascal>[1, 2, [10, 20, 30], 3, 4];
list[value]: [
1,
2,
[10,20,30],
3,
4
]

The effect of splicing the same list element in the enclosing list gives a flat list of type list[int]:

rascal>[1, 2, *[10, 20, 30], 3, 4];
list[int]: [1,2,10,20,30,3,4]

The same example can be written as:

rascal>L = [10, 20, 30];
list[int]: [10,20,30]
rascal>[1, 2, *L, 3, 4];
list[int]: [1,2,10,20,30,3,4]

Benefits

in which nested lists are handled.