1.1.7 Tutorial: lists |
Example |
/**/ [2,3,5]; // list containing the elements 2,3,5 in that order [2, 3, 5] /**/ 1..5; // integer range [1, 2, 3, 4, 5] // Now create a list using "append": /**/ L := []; // start with the empty list in L /**/ for i := 1 to 5 do append(ref L, i^2); endfor; /**/ println L; [1, 4, 9, 16, 25] /**/ [ n in L | IsEven(n)]; // list containing even values [4, 16] /**/ [ n^2 | n in L and n < 10]; [1, 16, 81] /**/ len(L); 5 /**/ foreach n in L do print n," "; endforeach; 1 4 9 16 25 |