From da80f2aa1cd6326d0fc8621a5cfb0e7fd313e192 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 15 Aug 2011 10:22:09 -0400 Subject: List.mapXi --- lib/ur/list.ur | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/ur/list.ur') 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 + [] => + | x :: ls => {f i x}{mapX' (i + 1) ls} + in + mapX' 0 + end + fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f = let fun mapM' acc ls = -- cgit v1.2.3