Mercurial > urweb
annotate tests/list.ur @ 757:fa2019a63ea4
Basis.list
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 30 Apr 2009 11:07:29 -0400 |
parents | 71bafe66dbe1 |
children | 8323c1beef2e |
rev | line source |
---|---|
adamc@757 | 1 fun isNil (t ::: Type) (ls : list t) = |
adamc@757 | 2 case ls of |
adamc@757 | 3 Nil => True |
adamc@757 | 4 | _ => False |
adamc@196 | 5 |
adamc@757 | 6 fun delist (ls : list string) : xbody = |
adamc@757 | 7 case ls of |
adamc@757 | 8 Nil => <xml>Nil</xml> |
adamc@757 | 9 | Cons (h, t) => <xml>{[h]} :: {delist t}</xml> |
adamc@196 | 10 |
adamc@757 | 11 fun main () = return <xml><body> |
adamc@757 | 12 {[isNil (Nil : list bool)]}, |
adamc@757 | 13 {[isNil (Cons (1, Nil))]}, |
adamc@757 | 14 {[isNil (Cons ("A", Cons ("B", Nil)))]} |
adamc@196 | 15 |
adamc@757 | 16 <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p> |
adamc@757 | 17 </body></xml> |