4 var buffer := getchar()
6 function readint(any: any) : int =
8 function isdigit(s : string) : int =
9 ord(buffer)>=ord("0") & ord(buffer)<=ord("9")
11 while buffer=" " | buffer="\n"
12 do buffer := getchar()
14 any.any := isdigit(buffer);
16 do (i := i*10+ord(buffer)-ord("0"); buffer := getchar());
20 type list = {first: int, rest: list}
22 function readlist() : list =
23 let var any := any{any=0}
26 then list{first=i,rest=readlist()}
30 function merge(a: list, b: list) : list =
33 else if a.first < b.first
34 then list{first=a.first,rest=merge(a.rest,b)}
35 else list{first=b.first,rest=merge(a,b.rest)}
37 function printint(i: int) =
38 let function f(i:int) = if i>0
39 then (f(i/10); print(chr(i-i/10*10+ord("0"))))
40 in if i<0 then (print("-"); f(-i))
45 function printlist(l: list) =
46 if l=nil then print("\n")
47 else (printint(l.first); print(" "); printlist(l.rest))
49 var list1 := readlist()
50 var list2 := (buffer:=getchar(); readlist())
53 /* BODY OF MAIN PROGRAM */
54 in printlist(merge(list1,list2))