[MLton-commit] r5226

Matthew Fluet fluet at mlton.org
Fri Feb 16 14:36:47 PST 2007


Catching up with changes to unfoldi
----------------------------------------------------------------------

U   mlton/trunk/lib/mlton/basic/resizable-array.fun
U   mlton/trunk/lib/mlton/set/hashed-unique-set.fun

----------------------------------------------------------------------

Modified: mlton/trunk/lib/mlton/basic/resizable-array.fun
===================================================================
--- mlton/trunk/lib/mlton/basic/resizable-array.fun	2007-02-16 19:38:43 UTC (rev 5225)
+++ mlton/trunk/lib/mlton/basic/resizable-array.fun	2007-02-16 22:36:46 UTC (rev 5226)
@@ -76,14 +76,20 @@
    Array (open A'
           val unsafeSub = sub
           val unsafeUpdate = update
-          val unfoldi: int * 'a * (int * 'a -> 'b * 'a) -> 'b t =
+          val unfoldi: int * 'a * (int * 'a -> 'b * 'a) -> 'b t * 'a =
              fn (n, ac, f) =>
-             T {array = ref (Array.unfoldi (n, ac, fn (i, a) =>
-                                            let
-                                               val (b, a') = f (i, a)
-                                            in (SOME b, a')
-                                            end)),
-                length = ref n})
+             let
+                val (arr, z) =
+                   Array.unfoldi (n, ac, fn (i, a) =>
+                                  let
+                                     val (b, a') = f (i, a)
+                                  in (SOME b, a')
+                                  end)
+             in
+                (T {array = ref arr,
+                    length = ref n},
+                 z)
+             end)
 
 open A' A''
 

Modified: mlton/trunk/lib/mlton/set/hashed-unique-set.fun
===================================================================
--- mlton/trunk/lib/mlton/set/hashed-unique-set.fun	2007-02-16 19:38:43 UTC (rev 5225)
+++ mlton/trunk/lib/mlton/set/hashed-unique-set.fun	2007-02-16 22:36:46 UTC (rev 5226)
@@ -50,7 +50,7 @@
       val n = Vector.length buckets
 
       val buckets
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (2 * n,
            ([], false),
            fn (i, (l, b))
@@ -81,7 +81,7 @@
       val n = (Vector.length buckets) div 2
 
       val buckets
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (n,
            (),
            fn (i, _) => let
@@ -164,7 +164,7 @@
       val T (ref {buckets, mask}) = s
 
       val buckets
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (Vector.length buckets,
            (),
            fn (i, _) => let
@@ -182,7 +182,7 @@
       val T (ref {buckets = buckets2, mask}) = s2
 
       val buckets
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (Vector.length buckets1,
            (),
            fn (i, _) => let
@@ -218,7 +218,7 @@
              val T (ref {buckets, mask}) = s
              val ix = index(hash x, mask)
              val buckets
-               = Vector.unfoldi
+               = (#1 o Vector.unfoldi)
                  (Vector.length buckets,
                   (),
                   fn (i, _) 
@@ -240,7 +240,7 @@
              val T (ref {buckets, mask}) = s
              val ix = index(hash x, mask)
              val buckets
-               = Vector.unfoldi
+               = (#1 o Vector.unfoldi)
                  (Vector.length buckets,
                   (),
                   fn (i, _) 
@@ -271,14 +271,14 @@
                   no = no'::no}
                end)
       val yes 
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (n,
            List.rev yes,
            fn (_, l) => case l
                           of h::t => (h, t)
                            | _ => Error.bug "HashedUniqueSet.partition.yes")
       val no
-        = Vector.unfoldi
+        = (#1 o Vector.unfoldi)
           (n,
            List.rev no,
            fn (_, l) => case l




More information about the MLton-commit mailing list