comparison src/list_util.sml @ 34:44b5405e74c7

Elaborating module projection
author Adam Chlipala <adamc@hcoop.net>
date Tue, 17 Jun 2008 16:38:54 -0400
parents 1c91c5e6840f
children 02f42e9a1825
comparison
equal deleted inserted replaced
33:535c324f0b35 34:44b5405e74c7
43 | S.Continue (t', s) => S.Continue (h' :: t', s) 43 | S.Continue (t', s) => S.Continue (h' :: t', s)
44 in 44 in
45 mf 45 mf
46 end 46 end
47 47
48 fun mapfoldB f =
49 let
50 fun mf ctx ls s =
51 case ls of
52 nil => S.Continue (nil, s)
53 | h :: t =>
54 let
55 val (ctx, r) = f (ctx, h)
56 in
57 case r s of
58 S.Return x => S.Return x
59 | S.Continue (h', s) =>
60 case mf ctx t s of
61 S.Return x => S.Return x
62 | S.Continue (t', s) => S.Continue (h' :: t', s)
63 end
64 in
65 mf
66 end
67
48 fun foldlMap f s = 68 fun foldlMap f s =
49 let 69 let
50 fun fm (ls', s) ls = 70 fun fm (ls', s) ls =
51 case ls of 71 case ls of
52 nil => (rev ls', s) 72 nil => (rev ls', s)