Mercurial > urweb
annotate tests/nest.ur @ 448:85819353a84f
First Unnest tests working
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 01 Nov 2008 15:58:55 -0400 |
parents | |
children | 07f6576aeb0a |
rev | line source |
---|---|
adamc@448 | 1 fun add x = |
adamc@448 | 2 let |
adamc@448 | 3 fun add' y = x + y |
adamc@448 | 4 in |
adamc@448 | 5 add' 1 + add' 2 |
adamc@448 | 6 end |
adamc@448 | 7 |
adamc@448 | 8 fun f (x : int) = |
adamc@448 | 9 let |
adamc@448 | 10 fun page () = return <xml><body> |
adamc@448 | 11 <a link={page ()}>{[x]}</a> |
adamc@448 | 12 </body></xml> |
adamc@448 | 13 in |
adamc@448 | 14 page |
adamc@448 | 15 end |
adamc@448 | 16 |
adamc@448 | 17 fun f (x : int) = |
adamc@448 | 18 let |
adamc@448 | 19 fun page1 () = return <xml><body> |
adamc@448 | 20 <a link={page2 ()}>{[x]}</a> |
adamc@448 | 21 </body></xml> |
adamc@448 | 22 |
adamc@448 | 23 and page2 () = |
adamc@448 | 24 case Some True of |
adamc@448 | 25 Some r => return <xml><body><a link={page1 ()}>{[r]}</a></body></xml> |
adamc@448 | 26 | _ => return <xml>Error</xml> |
adamc@448 | 27 in |
adamc@448 | 28 page1 |
adamc@448 | 29 end |
adamc@448 | 30 |
adamc@448 | 31 datatype list t = Nil | Cons of t * list t |
adamc@448 | 32 |
adamc@448 | 33 fun length (t ::: Type) (ls : list t) = |
adamc@448 | 34 let |
adamc@448 | 35 fun length' ls acc = |
adamc@448 | 36 case ls of |
adamc@448 | 37 Nil => acc |
adamc@448 | 38 | Cons (_, ls') => length' ls' (acc + 1) |
adamc@448 | 39 in |
adamc@448 | 40 length' ls 0 |
adamc@448 | 41 end |