diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-06-17 16:38:54 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-06-17 16:38:54 -0400 |
commit | b9406323848c150f5a8562ad206916c446529d65 (patch) | |
tree | 5464b011b61ca366be29dabd74275245b60659b9 /src/list_util.sml | |
parent | 4bb0bbc1920b5474619cb00e278590e029cdb12a (diff) |
Elaborating module projection
Diffstat (limited to 'src/list_util.sml')
-rw-r--r-- | src/list_util.sml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/list_util.sml b/src/list_util.sml index 7d3f8333..e3d8515e 100644 --- a/src/list_util.sml +++ b/src/list_util.sml @@ -45,6 +45,26 @@ fun mapfold f = mf end +fun mapfoldB f = + let + fun mf ctx ls s = + case ls of + nil => S.Continue (nil, s) + | h :: t => + let + val (ctx, r) = f (ctx, h) + in + case r s of + S.Return x => S.Return x + | S.Continue (h', s) => + case mf ctx t s of + S.Return x => S.Return x + | S.Continue (t', s) => S.Continue (h' :: t', s) + end + in + mf + end + fun foldlMap f s = let fun fm (ls', s) ls = |