comparison tests/list.ur @ 244:71bafe66dbe1

Laconic -> Ur
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 08:32:18 -0400
parents tests/list.lac@890a61991263
children fa2019a63ea4
comparison
equal deleted inserted replaced
243:2b9dfaffb008 244:71bafe66dbe1
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>