Mercurial > urweb
diff src/list_util.sml @ 792:d20d6afc1206
Improvements while working on Graftid
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 12 May 2009 18:02:25 -0400 |
parents | e0ed0d4dabc9 |
children | b2413e4dd109 |
line wrap: on
line diff
--- a/src/list_util.sml Sun May 10 10:13:41 2009 -0400 +++ b/src/list_util.sml Tue May 12 18:02:25 2009 -0400 @@ -146,6 +146,16 @@ m 0 [] end +fun appi f = + let + fun m i ls = + case ls of + [] => () + | h :: t => (f (i, h); m (i + 1) t) + in + m 0 + end + fun foldli f = let fun m i acc ls = @@ -178,4 +188,16 @@ fm (0, [], s) end +fun appn f n = + let + fun iter m = + if m >= n then + () + else + (f m; + iter (m + 1)) + in + iter 0 + end + end