comparison 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
comparison
equal deleted inserted replaced
791:5368deb3764b 792:d20d6afc1206
144 | h :: t => m (i + 1) (f (i, h) :: acc) t 144 | h :: t => m (i + 1) (f (i, h) :: acc) t
145 in 145 in
146 m 0 [] 146 m 0 []
147 end 147 end
148 148
149 fun appi f =
150 let
151 fun m i ls =
152 case ls of
153 [] => ()
154 | h :: t => (f (i, h); m (i + 1) t)
155 in
156 m 0
157 end
158
149 fun foldli f = 159 fun foldli f =
150 let 160 let
151 fun m i acc ls = 161 fun m i acc ls =
152 case ls of 162 case ls of
153 [] => acc 163 [] => acc
176 end 186 end
177 in 187 in
178 fm (0, [], s) 188 fm (0, [], s)
179 end 189 end
180 190
191 fun appn f n =
192 let
193 fun iter m =
194 if m >= n then
195 ()
196 else
197 (f m;
198 iter (m + 1))
199 in
200 iter 0
201 end
202
181 end 203 end