[svn] r6094: nemerle/trunk/lib/rlist.n
d
svnadmin at nemerle.org
Mon Jan 30 12:04:01 CET 2006
Log:
Drop the naive implementation of FromList (xs), always use FromList (xs, i).
Author: d
Date: Mon Jan 30 12:04:00 2006
New Revision: 6094
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 12:04:00 2006
@@ -118,7 +118,7 @@
</returns>
*/
public static Equals (xs : RList ['a], ys : RList ['a]) : bool {
- | (Zero (ps), Zero (qs)) => RList [Pair ['a]].Equals (ps, qs)
+ | (Zero (ps), Zero (qs))
| (One (x, ps), One (y, qs)) when x.Equals (y) => RList [Pair ['a]].Equals (ps, qs)
| (Nil, Nil) => true
| _ => false
@@ -525,7 +525,8 @@
}
/** Returns an RList composed of the elements of list [xs].
- Time complexity: O (|xs| * log |xs|).
+ Use RList (xs, |xs|) if |xs| is known.
+ Time complexity: O (|xs|).
<param name="xs">
The list used when composing the return value.
</param>
@@ -534,7 +535,7 @@
</returns>
*/
public static FromList (xs : list ['a]) : RList ['a] {
- List.FoldLeft (List.Rev (xs), Nil (), Cons)
+ FromList (xs, xs.Length)
}
/* An auxillary function used by FromList (xs, i).
@@ -571,7 +572,7 @@
</returns>
*/
public static FromList (xs : list ['a], i : int) : RList ['a] {
- _FromList (xs, i + 1, fun (l) { match (l) { | x :: tl => (x, tl) | [] => throw Exception ("Empty") } })
+ _FromList (xs, i, fun (l) { match (l) { | x :: tl => (x, tl) | [] => throw Exception ("Empty") } })
}
/** Returns a list of elements of the RList [xs] in the same order.
More information about the svn
mailing list