[MLton-commit] r5346

Vesa Karvonen vesak at mlton.org
Tue Feb 27 02:03:15 PST 2007


Added foldClear.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/misc-util/unstable/queue.sig
U   mltonlib/trunk/com/ssh/misc-util/unstable/queue.sml

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

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/queue.sig
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/queue.sig	2007-02-27 08:02:20 UTC (rev 5345)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/queue.sig	2007-02-27 10:03:04 UTC (rev 5346)
@@ -18,5 +18,6 @@
    val deque : 'a t -> 'a Option.t
    val enque : 'a t -> 'a Effect.t
 
+   val foldClear : ('a * 's -> 's) -> 's -> 'a t -> 's
    val appClear : 'a Effect.t -> 'a t Effect.t
 end

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/queue.sml
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/queue.sml	2007-02-27 08:02:20 UTC (rev 5345)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/queue.sml	2007-02-27 10:03:04 UTC (rev 5346)
@@ -39,8 +39,10 @@
           NONE => NONE
         | SOME (a, n) => (front := n ; SOME a)
 
-   fun appClear ef q =
+   fun foldClear f s q =
        case deque q of
-          NONE => ()
-        | SOME v => (ef v : Unit.t ; appClear ef q)
+          NONE => s
+        | SOME v => foldClear f (f (v, s)) q
+
+   fun appClear ef = foldClear (ef o #1) ()
 end




More information about the MLton-commit mailing list