[svn] r6472: nemerle/trunk/lib/narray.n

VladD2 svnadmin at nemerle.org
Thu Jul 27 16:02:34 CEST 2006


Log:
Add ToArrayFiltered()

Author: VladD2
Date: Thu Jul 27 16:02:32 2006
New Revision: 6472

Modified:
   nemerle/trunk/lib/narray.n

Modified: nemerle/trunk/lib/narray.n
==============================================================================
--- nemerle/trunk/lib/narray.n	(original)
+++ nemerle/trunk/lib/narray.n	Thu Jul 27 16:02:32 2006
@@ -439,6 +439,22 @@
       }
     }
 
+    /** Convert sequence to array with filtration. */
+    public ToArrayFiltered[T] (this sourse : SCG.IEnumerable [T], isMatch : T -> bool) : array [T]
+    {
+      match (sourse)
+      {
+        | null => array (0);
+        | _ =>
+          def dest = SCG.List();
+
+          foreach (elem when isMatch(elem) in sourse)
+            dest.Add(elem);
+            
+          dest.ToArray()
+      }
+    }
+
     /** Attention! It's inplace sort. */
     public SortInplace[T] (this sourse : array [T], comparison : System.Comparison[T]) : array [T]
     {



More information about the svn mailing list