[svn] r6370: nemerle/trunk: lib/narray.n
ncc/testsuite/completion-playground/compl3.n
VladD2
svnadmin at nemerle.org
Tue Jun 6 14:37:18 CEST 2006
Log:
Add some conversion function to NArray.
Author: VladD2
Date: Tue Jun 6 14:37:16 2006
New Revision: 6370
Modified:
nemerle/trunk/lib/narray.n
nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
Modified: nemerle/trunk/lib/narray.n
==============================================================================
--- nemerle/trunk/lib/narray.n (original)
+++ nemerle/trunk/lib/narray.n Tue Jun 6 14:37:16 2006
@@ -348,5 +348,36 @@
loop (a, 0)
}
+
+ /**
+ * Cast array to covariant subtype.
+ */
+ public ToBase[Derive, Base] (this sourse : array [Derive]) : array [Base]
+ where Base: class
+ where Derive: Base, class
+ {
+ (sourse : object) :> array [Base]
+ }
+
+ /**
+ * Convert array of one type to other.
+ */
+ public ConvertTo[From, To] (this sourse : array [From], f : From -> To) : array [To]
+ {
+ mutable dest = array(sourse.Length);
+
+ for (mutable i = 0; i < sourse.Length; i++)
+ dest[i] = f (sourse[i]);
+
+ dest;
+ }
+
+ /**
+ * Convert array to string.
+ */
+ public ToString['a] (this sourse : array ['a], separator : string) : string
+ {
+ string.Join(separator, sourse.ConvertTo(value => value.ToString()));
+ }
}
} /* end of namespace */
Modified: nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/completion-playground/compl3.n (original)
+++ nemerle/trunk/ncc/testsuite/completion-playground/compl3.n Tue Jun 6 14:37:16 2006
@@ -30,12 +30,16 @@
//def _second_tree = engine.GetTypeTree ();
// mutable the_method = null;
+mutable count = 0;
+
def loop (x) : IMember
{
mutable completionMember;
foreach (node in x.Children.Values)
{
+ count++;
+ //WriteLine (node.Name.ToString("."));
match (node.Value)
{
| NamespaceReference => completionMember = loop (node);
@@ -72,6 +76,7 @@
WriteLine ("Found types\n===========");
def completionMember = loop (type_tree);
+WriteLine ($"\n $count types found \n===========");
WriteLine ("\n================================================");
WriteLine ($" Completion member: $completionMember");
More information about the svn
mailing list