comparison 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
comparison
equal deleted inserted replaced
312:f387d12193ba 313:e0ed0d4dabc9
161 val len = length ls 161 val len = length ls
162 in 162 in
163 foldli (fn (n, x, s) => f (len - n - 1, x, s)) i (rev ls) 163 foldli (fn (n, x, s) => f (len - n - 1, x, s)) i (rev ls)
164 end 164 end
165 165
166 fun foldliMap f s =
167 let
168 fun fm (n, ls', s) ls =
169 case ls of
170 nil => (rev ls', s)
171 | h :: t =>
172 let
173 val (h', s') = f (n, h, s)
174 in
175 fm (n + 1, h' :: ls', s') t
176 end
177 in
178 fm (0, [], s)
179 end
180
166 end 181 end