[svn] r6100: nemerle/trunk/lib/rlist.n

d svnadmin at nemerle.org
Mon Jan 30 21:01:09 CET 2006


Log:
Add Append (+ some minor fixes).


Author: d
Date: Mon Jan 30 21:01:08 2006
New Revision: 6100

Modified:
   nemerle/trunk/lib/rlist.n

Modified: nemerle/trunk/lib/rlist.n
==============================================================================
--- nemerle/trunk/lib/rlist.n	(original)
+++ nemerle/trunk/lib/rlist.n	Mon Jan 30 21:01:08 2006
@@ -502,7 +502,7 @@
     }      
 
     /** Returns an RList composed by reversing [xs].
-        Time complexity: O (|xs|).
+        Time complexity: O (|xs| * log (|xs|)).
         <param name="xs">
           The RList used when composing the return value.
         </param>
@@ -515,7 +515,7 @@
     }
 
     /** Returns an RList composed by reversing [this].
-        Time complexity: O (|this|).
+        Time complexity: O (|this| * log (|this|)).
         <returns>
           An RList composed by reversing [this].
         </returns>
@@ -524,6 +524,37 @@
       Rev (this)
     }
 
+    /** Returns an a new RList composed by appending [ys]
+        at the end of [xs].
+        Time complexity: O (|xs| * log (|xs|)).
+        <param name="xs">
+          The RList, which elements come first in the resulting RList.
+        </param>
+        <param name="ys">
+          The RList, which elements come second in the resulting RList.
+        </param>
+        <returns>
+          An RListcomposed by appending [ys] at the end of [xs]. 
+        </returns>
+     */
+    public static Append (xs : RList ['a], ys : RList ['a]) : RList ['a] {
+      FoldRight (xs, ys, Cons)
+    }   
+
+    /** Returns an a new RList composed by appending [ys]
+        at the end of [this].
+        Time complexity: O (|this| * log (|this|)).
+        <param name="ys">
+          The RList, which elements come second in the resulting RList.
+        </param>
+        <returns>
+          An RListcomposed by appending [ys] at the end of [this]. 
+        </returns>
+     */
+    public Append (ys : RList ['a]) : RList ['a] {
+      FoldRight (this, ys, Cons)
+    }   
+
     /** Returns an RList composed of the elements of list [xs].
         Use RList (xs, |xs|) if |xs| is known.
         Time complexity: O (|xs|).
@@ -585,7 +616,7 @@
         </returns>
      */
     public static ToList (xs : RList ['a]) : list ['a] {
-      List.Rev (FoldLeft (xs, [], _ :: _))
+      FoldRight (xs, [], _ :: _)
     }
 
     /** Returns a list of elements of the RList [this] in the same order.



More information about the svn mailing list