summaryrefslogtreecommitdiff
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-06-16 17:52:44 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-06-16 17:52:44 -0400
commit8c2eb37e99b79153a98fbdebce39b4064dcdb2e9 (patch)
tree03a63951b832edfdb7a5c7cb9c05345c0f097248 /lib/ur/list.ur
parent4dce690086c8d6132c22d5c47a0561a4b1261293 (diff)
Fix a variable capture bug in nested JavaScript; some more list stuff
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index b99ef515..d774cc54 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -31,17 +31,17 @@ fun foldl [a] [b] f =
foldl'
end
-fun foldlPartial [a] [b] f =
+fun foldlAbort [a] [b] f =
let
- fun foldlPartial' acc ls =
+ fun foldlAbort' acc ls =
case ls of
[] => Some acc
| x :: ls =>
case f x acc of
None => None
- | Some acc' => foldlPartial' acc' ls
+ | Some acc' => foldlAbort' acc' ls
in
- foldlPartial'
+ foldlAbort'
end
val rev = fn [a] =>
@@ -54,6 +54,19 @@ val rev = fn [a] =>
rev' []
end
+fun foldlMapAbort [a] [b] [c] f =
+ let
+ fun foldlMapAbort' ls' acc ls =
+ case ls of
+ [] => Some (rev ls', acc)
+ | x :: ls =>
+ case f x acc of
+ None => None
+ | Some (x', acc') => foldlMapAbort' (x' :: ls') acc' ls
+ in
+ foldlMapAbort' []
+ end
+
val revAppend = fn [a] =>
let
fun ra (ls : list a) acc =