[svn] r6914: nemerle/trunk/lib: list.n oldapi.n
VladD2
svnadmin at nemerle.org
Thu Nov 16 19:44:13 CET 2006
Log:
Add IsOrdered method to list[a']
Author: VladD2
Date: Thu Nov 16 19:44:12 2006
New Revision: 6914
Modified:
nemerle/trunk/lib/list.n
nemerle/trunk/lib/oldapi.n
Modified: nemerle/trunk/lib/list.n
==============================================================================
--- nemerle/trunk/lib/list.n (original)
+++ nemerle/trunk/lib/list.n Thu Nov 16 19:44:12 2006
@@ -472,6 +472,23 @@
NCL.Sort (this, cmp)
}
+ public static IsOrdered [T] (this lst : list[T], great : T * T -> bool) : bool
+ {
+ match (lst)
+ {
+ | first :: (second :: _) as tail =>
+ if (great (first, second)) false else IsOrdered (tail, great)
+
+ | [_] | [] | null => true
+ }
+ }
+
+ public static IsOrdered[T](this lst : list[T]) : bool
+ where T: System.IComparable[T]
+ {
+ IsOrdered(lst, (x, y) => x.CompareTo(y) > 0)
+ }
+
public RemoveDuplicates () : list ['a]
{
Modified: nemerle/trunk/lib/oldapi.n
==============================================================================
--- nemerle/trunk/lib/oldapi.n (original)
+++ nemerle/trunk/lib/oldapi.n Thu Nov 16 19:44:12 2006
@@ -88,7 +88,7 @@
///
/// just an alias for older API compatibility
public type NemerleMap ['a, 'b]
- where 'a : Nemerle.IComparable ['a] = Map ['a, 'b];
+ where 'a : System.IComparable ['a] = Map ['a, 'b];
/** OBSOLETE
*
More information about the svn
mailing list