Navigation
Synopsis Append an element to the list value produced by various loop statements.
Syntax append 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]

Questions
Question [1]. Complete this function that finds duplicates in a list of strings
Fill in
text = ["the", "jaws", "that", "bite", "the", "claws", "that", "catch"];
public list[str] duplicates(list[str] text){
    m = {};
    return 
      for(s <- text)
        if()
           append s;
        else
           m += s;
}
and make the following true:
duplicates(text) == ["the", "that"];



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.