Mercurial > urweb
annotate tests/list.lac @ 225:5ac2cf59b839
Change [sql_field] type to get 'where' test to check again
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 21 Aug 2008 13:47:18 -0400 |
parents | 890a61991263 |
children |
rev | line source |
---|---|
adamc@196 | 1 datatype list a = Nil | Cons of a * list a |
adamc@196 | 2 |
adamc@196 | 3 val isNil = fn t ::: Type => fn ls : list t => |
adamc@196 | 4 case ls of Nil => True | _ => False |
adamc@196 | 5 |
adamc@196 | 6 val show = fn b => if b then "True" else "False" |
adamc@196 | 7 |
adamc@196 | 8 val rec delist : list string -> xml body [] [] = fn x => |
adamc@196 | 9 case x of |
adamc@196 | 10 Nil => <body>Nil</body> |
adamc@196 | 11 | Cons (h, t) => <body>{cdata h} :: {delist t}</body> |
adamc@196 | 12 |
adamc@196 | 13 val main : unit -> page = fn () => <html><body> |
adamc@196 | 14 {cdata (show (isNil (Nil : list bool)))}, |
adamc@196 | 15 {cdata (show (isNil (Cons (1, Nil))))}, |
adamc@196 | 16 {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))} |
adamc@196 | 17 |
adamc@196 | 18 <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p> |
adamc@196 | 19 </body></html> |