Mercurial > urweb
comparison demo/list.ur @ 397:4d519baf357c
ListShop skeleton
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 21 Oct 2008 12:06:35 -0400 |
parents | |
children | 7ef4b2911b09 |
comparison
equal
deleted
inserted
replaced
396:040edfade639 | 397:4d519baf357c |
---|---|
1 datatype list t = Nil | Cons of t * list t | |
2 | |
3 fun length' (t ::: Type) (ls : list t) (acc : int) = | |
4 case ls of | |
5 Nil => acc | |
6 | Cons (_, ls') => length' ls' (acc + 1) | |
7 | |
8 fun length (t ::: Type) (ls : list t) = length' ls 0 | |
9 | |
10 fun rev' (t ::: Type) (ls : list t) (acc : list t) = | |
11 case ls of | |
12 Nil => acc | |
13 | Cons (x, ls') => rev' ls' (Cons (x, acc)) | |
14 | |
15 fun rev (t ::: Type) (ls : list t) = rev' ls Nil |