Mercurial > urweb
diff src/list_util.sml @ 313:e0ed0d4dabc9
Termination checking
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 09 Sep 2008 11:46:33 -0400 |
parents | 73456bfde988 |
children | d20d6afc1206 |
line wrap: on
line diff
--- a/src/list_util.sml Tue Sep 09 09:15:00 2008 -0400 +++ b/src/list_util.sml Tue Sep 09 11:46:33 2008 -0400 @@ -163,4 +163,19 @@ foldli (fn (n, x, s) => f (len - n - 1, x, s)) i (rev ls) end +fun foldliMap f s = + let + fun fm (n, ls', s) ls = + case ls of + nil => (rev ls', s) + | h :: t => + let + val (h', s') = f (n, h, s) + in + fm (n + 1, h' :: ls', s') t + end + in + fm (0, [], s) + end + end