summaryrefslogtreecommitdiff
path: root/src/list_util.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/list_util.sml')
-rw-r--r--src/list_util.sml10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/list_util.sml b/src/list_util.sml
index fff3e78e..976e4708 100644
--- a/src/list_util.sml
+++ b/src/list_util.sml
@@ -136,4 +136,14 @@ fun search f =
s
end
+fun mapi f =
+ let
+ fun m i acc ls =
+ case ls of
+ [] => rev acc
+ | h :: t => m (i + 1) (f (i, h) :: acc) t
+ in
+ m 0 []
+ end
+
end