[svn] r7660: nemerle/trunk/lib/list.n

VladD2 svnadmin at nemerle.org
Tue May 8 00:34:07 CEST 2007


Log:
Add Equals to list[].

Author: VladD2
Date: Tue May  8 00:34:05 2007
New Revision: 7660

Modified:
   nemerle/trunk/lib/list.n

Modified: nemerle/trunk/lib/list.n
==============================================================================
--- nemerle/trunk/lib/list.n	(original)
+++ nemerle/trunk/lib/list.n	Tue May  8 00:34:05 2007
@@ -112,6 +112,11 @@
       }
     }
 
+    public Equals[T2] (lst2 : list [T2], compare : 'a * T2 -> bool) : bool
+    {
+      NCL.Equals (this, lst2, compare)
+    }
+
     public override GetHashCode () : int
     {
       match (this){
@@ -355,6 +360,11 @@
       NCL.ForAll (this, f)
     }
     
+    public ForAll2[T2] (lst2 : list [T2], predicate : 'a * T2 -> bool) : bool 
+    {
+      NCL.ForAll2 (this, lst2, predicate)
+    }
+    
     /**
      * Returns 'true' if at least one of the 'l' list's elements
      * satisfies the condition 'f'.
@@ -1027,14 +1037,24 @@
      *
      * evaluates to 'true' as all the list's elements are even.
      */
-    public ForAll['a] (l : list ['a], f : 'a -> bool) : bool
+    public ForAll[T] (lst : list [T], predicate : T -> bool) : bool
     {
-      match (l) {
-        | x :: xs => f (x) && ForAll (xs, f)
+      match (lst) {
+        | x :: xs => predicate (x) && ForAll (xs, predicate)
         | [] => true
       }
     }
     
+    public Equals[T1, T2] (lst1 : list [T1], lst2 : list [T2], compare : T1 * T2 -> bool) : bool
+    {
+      match (lst1, lst2)
+      {
+        | (x1 :: xs1, x2 :: xs2) => compare (x1, x2) && Equals (xs1, xs2, compare)
+        | ([], []) => true
+        | _ => false
+      }
+    }
+
     /**
      * Returns 'true' if at least one of the 'l' list's elements
      * satisfies the condition 'f'.



More information about the svn mailing list