cw2_marking/c2.sc
changeset 978 8778d23fef92
equal deleted inserted replaced
977:1e6eca42d90b 978:8778d23fef92
       
     1 // for testing compilation
       
     2 import $file.cw02
       
     3 import cw02._
       
     4 
       
     5 val ufile = """
       
     6 // Collatz series
       
     7 //
       
     8 // needs writing of strings and numbers; comments
       
     9 
       
    10 bnd := 1;
       
    11 while bnd < 101 do {
       
    12   write bnd;
       
    13   write ": ";
       
    14   n := bnd;
       
    15   cnt := 0;
       
    16 
       
    17   while n > 1 do {
       
    18     write n;
       
    19     write ",";
       
    20     
       
    21     if n % 2 == 0 
       
    22     then n := n / 2 
       
    23     else n := 3 * n+1;
       
    24 
       
    25     cnt := cnt + 1
       
    26   };
       
    27 
       
    28   write " => ";
       
    29   write cnt;
       
    30   write "\n";
       
    31   bnd := bnd + 1
       
    32 }
       
    33 """
       
    34 
       
    35 
       
    36 println(tokenise(ufile))