[MLton-commit] r6627

Vesa Karvonen vesak at mlton.org
Fri May 30 06:05:08 PDT 2008


Added findSome, merge, and for (app reversed).
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/sequence/list.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/list.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/sequence/list.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/sequence/list.sml	2008-05-29 18:00:40 UTC (rev 6626)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/sequence/list.sml	2008-05-30 13:05:04 UTC (rev 6627)
@@ -63,6 +63,9 @@
       lp
    end
    fun concatMap f = rev o foldl (revAppend o Pair.map (f, Fn.id)) []
+   fun findSome x2yO =
+    fn []    => NONE
+     | x::xs => case x2yO x of NONE => findSome x2yO xs | SOME y => SOME y
    fun appr e = app e o rev
    fun foldli f y = #2 o foldl (fn (x, (i, y)) => (i+1, f (i+1, x, y))) (~1, y)
    fun foldri f y xs = let
@@ -123,6 +126,7 @@
    in
       revAppend (lp (xs, ys, []))
    end
+   fun merge compare = rev o revMerge compare
    fun stableSort compare xs = let
       (* This optimized implementation of merge sort tries to minimize
        * list reversals by performing reverse merges and flipping the
@@ -164,4 +168,5 @@
    end
    val sort = stableSort
    fun iso ? = Pair.map (map, map) ?
+   fun for xs ef = app ef xs
 end

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/list.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/list.sig	2008-05-29 18:00:40 UTC (rev 6626)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/sequence/list.sig	2008-05-30 13:05:04 UTC (rev 6627)
@@ -68,6 +68,10 @@
 
    val concatMap : ('a -> 'b t) -> 'a t -> 'b t
 
+   val findSome : ('a -> 'b Option.t) -> 'a t -> 'b Option.t
+
+   val for : 'a t -> 'a Effect.t Effect.t
+
    (** == Indexed HOFs == *)
 
    val appi : (Int.t * 'a) Effect.t -> 'a t Effect.t
@@ -122,6 +126,9 @@
 
    (** == Sorted Lists == *)
 
+   val merge : 'a Cmp.t -> 'a t BinOp.t
+   (** Merges two ordered lists. *)
+
    val sort : 'a Cmp.t -> 'a t UnOp.t
    (** Sorts given list to ascending order with respect to given ordering. *)
 
@@ -138,7 +145,7 @@
 
    (** == Operations using equivalence relations and partial orders ==
     *
-    * The {ByEq} functions use a binary predicate and operates in O(n^2)
+    * The {ByEq} functions use a binary predicate and operate in O(n^2)
     * time.  The binary predicate is assumed to be an equivalence
     * relation.
     *




More information about the MLton-commit mailing list