[MLton-commit] r6498

Vesa Karvonen vesak at mlton.org
Fri Mar 21 04:40:20 PST 2008


Added indexFrom and indexFromBy.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml	2008-03-21 10:45:11 UTC (rev 6497)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/control/iter.sml	2008-03-21 12:40:19 UTC (rev 6498)
@@ -25,7 +25,10 @@
    exception S
    fun (m until p) f = m (fn x => if p x then raise S else f x) handle S => ()
 
-   fun index m f = (fn i => m (fn a => f (a & !i before i := !i+1))) (ref 0)
+   fun indexFromBy i d m f =
+       (fn i => m (fn a => f (a & !i) before i := !i+d)) (ref i)
+   fun indexFrom i = indexFromBy i 1
+   fun index m = indexFrom 0 m
 
    fun iterate f = unfold (fn x => SOME (x, f x))
 

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig	2008-03-21 10:45:11 UTC (rev 6497)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/control/iter.sig	2008-03-21 12:40:19 UTC (rev 6498)
@@ -58,8 +58,14 @@
     * x(i) = false} for all {0<=i<=n} and {p x(n+1) = true}.
     *)
 
+   val indexFromBy : Int.t -> Int.t -> 'a t -> ('a, Int.t) Product.t t
+   (** {indexFromBy i d [<x(0), x(1), ...>] = [<x(0) & i+0*d, x(1) & i+1*d, ...>]} *)
+
+   val indexFrom : Int.t -> 'a t -> ('a, Int.t) Product.t t
+   (** {indexFrom i = indexFromBy i 1} *)
+
    val index : 'a t -> ('a, Int.t) Product.t t
-   (** {index [<x(0), x(1), ...>] = [<x(0) & 0, x(1) & 1, ...>]} *)
+   (** {index = indexFrom 0} *)
 
    val iterate : 'a UnOp.t -> 'a -> 'a t
    (** {iterate f x = [<x, f x, f (f x), ...>]} *)




More information about the MLton-commit mailing list