diff lib/ur/list.ur @ 1539:dde3bd82cb3d

List.mapXi
author Adam Chlipala <adam@chlipala.net>
date Mon, 15 Aug 2011 10:22:09 -0400
parents ada582d07ae1
children 553a5cc3a4b5
line wrap: on
line diff
--- a/lib/ur/list.ur	Sun Aug 14 17:39:18 2011 -0400
+++ b/lib/ur/list.ur	Mon Aug 15 10:22:09 2011 -0400
@@ -133,6 +133,16 @@
         mapX'
     end
 
+fun mapXi [a] [ctx ::: {Unit}] f =
+    let
+        fun mapX' i ls =
+            case ls of
+                [] => <xml/>
+              | x :: ls => <xml>{f i x}{mapX' (i + 1) ls}</xml>
+    in
+        mapX' 0
+    end
+
 fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
     let
         fun mapM' acc ls =