summaryrefslogtreecommitdiff
path: root/src/list_util.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 20:07:10 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-13 20:07:10 -0400
commit811a3831805bf7a87ed3a64156f4ac6f6246edb9 (patch)
treea2bc2022ac4e0412a787a526135aafc99db66998 /src/list_util.sml
parent97cc749872a8baf53bb34ef1b536b82f6aa7f1c7 (diff)
Passing an argument to a web function
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