From 4f2c619bb0971153c518f120c8911ce3a94f783d Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 21 Nov 2010 15:43:24 -0500 Subject: Fix a bug in C list unurlification --- lib/ur/list.ur | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/ur/list.ur') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 71d8fa98..354ef132 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -308,6 +308,20 @@ fun sort [a] (gt : a -> a -> bool) (ls : t a) : t a = 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)) = -- cgit v1.2.3