Created
June 14, 2011 04:02
-
-
Save takeshik/1024292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using XSpect.Yacq.LanguageServices; | |
namespace yacqrun | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var result = ((Expression<Func<int, Func<int, Func<int, int>>>>) new Reader(@" | |
; this is comment (to end of line) | |
; All parameters is typed as System.Int32, yet. | |
; Following code returns x => y => z => x + y + z . | |
(\ [x] (\ [y] (\ [z] (+ x y z))))" | |
) | |
// This is just a charm, or like an idiom. Don't care. | |
.Read() | |
.Select(e => e.Reduce()) | |
.ToArray() | |
.Last() | |
).Compile() | |
// Invoke! | |
(100)(20)(3); | |
// Output the result with Console class. | |
((Expression<Action<int>>) new Reader(@" | |
(import-type Console 'System.Console') ; import System.Console class as ID 'Console' | |
(\ [x] (Console.(WriteLine x)))" | |
).Read().Select(e => e.Reduce()).ToArray().Last()).Compile()(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment