Skip to main content

Append

rascal-0.40.17

Synopsis

Append an element to the list value produced by various loop statements.

Syntax

append Exp

append Label: Exp

Description

An append statement may only occur in the body of a While, Do or For statement. It appends the value of Exp to the resulting list value of the loop construct in which it occurs.

Examples

rascal>for(int i <- [1..5]) 
>>>>>>> append i*i;
list[int]: [1,4,9,16]
rascal>L = for(int i <- [1..5])
>>>>>>> append i*i;
list[int]: [1,4,9,16]
rascal>
rascal>OUTER:for (int i <-[1..5])
>>>>>>> for (int j <- [1..5])
>>>>>>> append OUTER: <i,j>;
lrel[int,int]: [
<1,1>,
<1,2>,
<1,3>,
<1,4>,
<2,1>,
<2,2>,
<2,3>,
<2,4>,
<3,1>,
<3,2>,
<3,3>,
<3,4>,
<4,1>,
<4,2>,
<4,3>,
<4,4>
]