diff options
Diffstat (limited to 'src/list_util.sml')
-rw-r--r-- | src/list_util.sml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/list_util.sml b/src/list_util.sml index fdc1ac55..eee8249b 100644 --- a/src/list_util.sml +++ b/src/list_util.sml @@ -42,4 +42,22 @@ fun mapfoldl f i = mf i [] end +structure S = Search + +fun mapfold f = + let + fun mf ls s = + case ls of + nil => S.Continue (nil, s) + | h :: t => + case f h s of + S.Return x => S.Return x + | S.Continue (h', s) => + case mf t s of + S.Return x => S.Return x + | S.Continue (t', s) => S.Continue (h' :: t', s) + in + mf + end + end |