[svn] r6222: nemerle/trunk: macros/core.n
ncc/testsuite/positive/basic-macros.n ncc/testsuite/positive/ext...
nazgul
svnadmin at nemerle.org
Thu May 4 19:51:48 CEST 2006
Log:
Set proper priority for => lambda operator
Author: nazgul
Date: Thu May 4 19:51:39 2006
New Revision: 6222
Modified:
nemerle/trunk/macros/core.n
nemerle/trunk/ncc/testsuite/positive/basic-macros.n
nemerle/trunk/ncc/testsuite/positive/extension-methods.n
Modified: nemerle/trunk/macros/core.n
==============================================================================
--- nemerle/trunk/macros/core.n (original)
+++ nemerle/trunk/macros/core.n Thu May 4 19:51:39 2006
@@ -83,6 +83,8 @@
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "|=", false, 141, 140)]
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "when", false, 130, 131)]
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "with", false, 130, 131)]
+[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "=>", false, 121, 120)] // lambda expression
+
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "!", true, 281, 280)]
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.Core", "~", true, 281, 280)]
Modified: nemerle/trunk/ncc/testsuite/positive/basic-macros.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/basic-macros.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/basic-macros.n Thu May 4 19:51:39 2006
@@ -316,6 +316,11 @@
System.Console.WriteLine (brace (1));
def one = (x : int) => x + 1;
System.Console.WriteLine (one(1));
+ when ([2,4].ForAll (x => x % 2 == 0))
+ System.Console.WriteLine ("All : even");
+ def add : int -> int -> int = x => y => x + y;
+ def add_5 = add (5);
+ System.Console.WriteLine (add_5 (2));
}
@@ -418,5 +423,7 @@
aa
2
2
+All : even
+7
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/testsuite/positive/extension-methods.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/extension-methods.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/extension-methods.n Thu May 4 19:51:39 2006
@@ -3,6 +3,19 @@
using System.Console
using Nemerle.Collections
+module Extensions
+ public All [T] (this objs : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : bool
+ return :
+ foreach (o in objs)
+ when (!fn (o))
+ return (false)
+ return (true)
+
+def ls = $ [0, 2 .. 10] : System.Collections.Generic.IEnumerable [int]
+
+when (ls.All (x => x % 2 == 0))
+ WriteLine ("All : even")
+
B.Run ()
def a = A (42)
a.foo ()
@@ -26,6 +39,7 @@
/*
BEGIN-OUTPUT
+All : even
foo()
foo(42,1)
foo(42,2)
More information about the svn
mailing list