From b9406323848c150f5a8562ad206916c446529d65 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 17 Jun 2008 16:38:54 -0400 Subject: Elaborating module projection --- src/list_util.sml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/list_util.sml') 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 = -- cgit v1.2.3