Mercurial > urweb
diff lib/ur/list.ur @ 1322:80bff6449f41
Fix a bug in C list unurlification
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 21 Nov 2010 15:43:24 -0500 |
parents | 4172863d049d |
children | 9e0fa4f6ac93 |
line wrap: on
line diff
--- a/lib/ur/list.ur Sat Nov 20 10:45:22 2010 -0500 +++ b/lib/ur/list.ur Sun Nov 21 15:43:24 2010 -0500 @@ -308,6 +308,20 @@ sort' ls end +val nth [a] = + let + fun nth (ls : list a) (n : int) : option a = + case ls of + [] => None + | x :: ls' => + if n <= 0 then + Some x + else + nth ls' (n-1) + in + nth + end + fun assoc [a] [b] (_ : eq a) (x : a) = let fun assoc' (ls : list (a * b)) =