[MLton-commit] r4993

Vesa Karvonen vesak at mlton.org
Wed Dec 20 13:06:09 PST 2006


Added map to array modules.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/array.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/mk-mono-array-ext.fun
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/array.sig
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/mono-array.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/array.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/array.sml	2006-12-20 07:52:43 UTC (rev 4992)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/array.sml	2006-12-20 21:05:44 UTC (rev 4993)
@@ -14,4 +14,5 @@
    val toVector = vector
    fun fromVector v = tabulate (Vector.length v, fn i => Vector.sub (v, i))
    val isoVector = (toVector, fromVector)
+   fun map f a = tabulate (length a, fn i => f (sub (a, i)))
 end

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/mk-mono-array-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/mk-mono-array-ext.fun	2006-12-20 07:52:43 UTC (rev 4992)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/mk-mono-array-ext.fun	2006-12-20 21:05:44 UTC (rev 4993)
@@ -28,4 +28,5 @@
    val toVector = vector
    val isoVector = (toVector, fromVector)
    val isoPoly = (toPoly, fromPoly)
+   fun map f a = tabulate (length a, fn i => f (sub (a, i)))
 end

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/array.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/array.sig	2006-12-20 07:52:43 UTC (rev 4992)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/array.sig	2006-12-20 21:05:44 UTC (rev 4993)
@@ -24,6 +24,9 @@
     * bi+1) = f (i, bi)}.
     *)
 
+   val map : ('a -> 'b) -> 'a t -> 'b t
+   (** {map f} is equivalent to {fromVector o Vector.map f o toVector}. *)
+
    (** == Conversions == *)
 
    val fromVector : 'a Vector.t -> 'a t

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/mono-array.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/mono-array.sig	2006-12-20 07:52:43 UTC (rev 4992)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/mono-array.sig	2006-12-20 21:05:44 UTC (rev 4993)
@@ -24,6 +24,9 @@
     * bi+1) = f (i, bi)}.
     *)
 
+   val map : elem UnOp.t -> t UnOp.t
+   (** {map f} is equivalent to {fromVector o MonoVector.map f o toVector}. *)
+
    (** == Conversions == *)
 
    val fromPoly : elem Array.t -> t




More information about the MLton-commit mailing list