comparison tests/list.lac @ 196:890a61991263

Lists all the way through
author Adam Chlipala <adamc@hcoop.net>
date Sat, 09 Aug 2008 16:48:32 -0400
parents
children
comparison
equal deleted inserted replaced
195:85b5f663bb86 196:890a61991263
1 datatype list a = Nil | Cons of a * list a
2
3 val isNil = fn t ::: Type => fn ls : list t =>
4 case ls of Nil => True | _ => False
5
6 val show = fn b => if b then "True" else "False"
7
8 val rec delist : list string -> xml body [] [] = fn x =>
9 case x of
10 Nil => <body>Nil</body>
11 | Cons (h, t) => <body>{cdata h} :: {delist t}</body>
12
13 val main : unit -> page = fn () => <html><body>
14 {cdata (show (isNil (Nil : list bool)))},
15 {cdata (show (isNil (Cons (1, Nil))))},
16 {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))}
17
18 <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
19 </body></html>