diff lib/ur/list.ur @ 1279:4c367c8f5b2d

List.mapi
author Adam Chlipala <adamc@hcoop.net>
date Sun, 13 Jun 2010 14:13:47 -0400
parents 61c3139eab12
children 4172863d049d
line wrap: on
line diff
--- a/lib/ur/list.ur	Sun Jun 13 14:13:06 2010 -0400
+++ b/lib/ur/list.ur	Sun Jun 13 14:13:47 2010 -0400
@@ -101,6 +101,16 @@
         mp' []
     end
 
+fun mapi [a] [b] f =
+    let
+        fun mp' n acc ls =
+            case ls of
+                [] => rev acc
+              | x :: ls => mp' (n + 1) (f n x :: acc) ls
+    in
+        mp' 0 []
+    end
+
 fun mapPartial [a] [b] f =
     let
         fun mp' acc ls =