diff options
author | Adam Chlipala <adamc@hcoop.net> | 2010-06-13 14:13:47 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2010-06-13 14:13:47 -0400 |
commit | 2ed97b5268a73d4ff83ad776e5a6063f469f68fe (patch) | |
tree | 7853299e0060cd6c6eea28a26aa4ee33b1b93c21 /lib/ur/list.ur | |
parent | 3f4cbb5f7f9deef169728e445e5b69ef14fedd30 (diff) |
List.mapi
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r-- | lib/ur/list.ur | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur index bccbc82a..bb814714 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -101,6 +101,16 @@ fun mp [a] [b] f = mp' [] end +fun mapi [a] [b] f = + let + fun mp' n acc ls = + case ls of + [] => rev acc + | x :: ls => mp' (n + 1) (f n x :: acc) ls + in + mp' 0 [] + end + fun mapPartial [a] [b] f = let fun mp' acc ls = |