summaryrefslogtreecommitdiff
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-08-15 10:22:09 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-08-15 10:22:09 -0400
commitda80f2aa1cd6326d0fc8621a5cfb0e7fd313e192 (patch)
treed53efdcd64e016a6688ce67cb5b5b37c0758e9f6 /lib/ur/list.ur
parentc58370c7b4a4cc6027baf7b6ebfcc1dcab181666 (diff)
List.mapXi
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index 2679d877..35440de2 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -133,6 +133,16 @@ fun mapX [a] [ctx ::: {Unit}] f =
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 =