Navigation
Synopsis Splice the elements of a list in an enclosing list.
Syntax *Exp
Types
Exp Exp1 Expn [Exp1, ..., Exp, ..., Expn]
T T1 Tn list[lub(T1, ..., T, ...,Tn)]
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.
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.