diff lib/ur/list.ur @ 850:1c2f335297b7

Fix a variable capture bug in nested JavaScript; some more list stuff
author Adam Chlipala <adamc@hcoop.net>
date Tue, 16 Jun 2009 17:52:44 -0400
parents 0d30e6338c65
children ed06e25c70ef
line wrap: on
line diff
--- a/lib/ur/list.ur	Tue Jun 16 14:38:01 2009 -0400
+++ b/lib/ur/list.ur	Tue Jun 16 17:52:44 2009 -0400
@@ -31,17 +31,17 @@
         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 @@
                  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 =