![]() |
| ||||||||
Navigation |
Synopsis Splice the elements of a list in an enclosing list.
Syntax
*Exp
Types
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 The splicing operator gives full, explicit, control over the way
in which nested lists are handled.
![]() |