← | ↑ |
A program is a sequence of one or more definitions, one after another.
When a program is run, the language implementation evaluates the definition of main.
If main yields an action then the language implementation performs that action.
If main yields a result r that is not an action then the implementation prints the result, as if the result had been action print r.
Use the following rules for printing.
|
def main = cat a b end def a = [2, 4, 6] end def b = [8, 10] end def cat x y = case isNull x => y | else => head x : cat (tail x) y end end |
prints
2:4:6:8:10:[]
def main = printList ['H','o','w',' ', 'm','a','n','y',' ', 's','e','c','o', 'n','d','s','?']; readInt ~> (n -> let m = n/60 in let h = n/3600 in let secs = n - 60*m in let mins = m - 60*h in printList [h, ':', mins, ':', secs] end end end end ) end |
reads a number then prints it as hours, minutes, seconds. For example, if it reads 1000 then it prints
0:16:40