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
typeof(Action<>).MakeGenericType(c.Event.EventHandlerType).Let(t => Call( | |
typeof(Observable), | |
"FromEventPattern", | |
new [] | |
{ | |
c.Event.EventHandlerType, | |
c.Event.EventHandlerType.GetMethod("Invoke").GetParameters()[1].ParameterType, | |
}, | |
Convert(Call( | |
typeof(Delegate), |
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
(alias [F Func.[Int32 Int32 Int32 Int32]] (let [tarai:F] | |
(= tarai (\ [x:Int32 y:Int32 z:Int32] (< y x) | |
.(cond | |
(tarai | |
(tarai (-- x) y z) | |
(tarai (-- y) z x) | |
(tarai (-- z) x y) | |
) | |
y | |
) |
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
// -*- mode: csharp; encoding: utf-8; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- | |
// vim:set ft=cs fenc=utf-8 ts=4 sw=4 sts=4 et: | |
// $Id: 919a6613587c54febc8e1cd4b01afd21fd5dbc78 $ | |
/* YACQ | |
* Yet Another Compilable Query Language, based on Expression Trees API | |
* Copyright © 2011 Takeshi KIRIYA (aka takeshik) <[email protected]> | |
* All rights reserved. | |
* | |
* This file is part of YACQ. | |
* |
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
var p = Expression.Parameter(typeof(int)); | |
var expr = Expression.Lambda<Action>( | |
Expression.Call( | |
typeof(EnumerableEx), | |
"ForEach", | |
new [] { typeof(int) }, | |
Expression.Call( | |
typeof(Enumerable), | |
"Range", | |
Type.EmptyTypes, |
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
private static SymbolTable CreatePathSymbols(SymbolTable symbols, IEnumerable<String> fragments) | |
{ | |
return EnumerableEx.Generate( | |
Tuple.Create(fragments, symbols), | |
_ => _.Item1.Any(), | |
_ => Tuple.Create(_.Item1.Skip(1), _.Item1.First() | |
.Let(f => _.Item2.ExistsKey(f) && _.Item2.Resolve(f).Const<SymbolTable>() != null | |
? symbols.Resolve(f).Const<SymbolTable>() | |
: new SymbolTable().Apply(s => _.Item2[f] = Expression.Constant(s)) | |
)), |
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
abstract class X | |
{ | |
public abstract T Get<T>(); | |
public object P { get { return this.Get<Object>(); } } | |
} | |
class X<T> : X | |
{ | |
public override T Get<T>() { return default(T); } | |
public T Get() { return this.Get<T>(); } |
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
(assembly "LinqToTwitter") | |
(load "cts:System.Diagnostics") | |
(import "cts:LinqToTwitter" "T") | |
T.PinAuthorizer.(new).(with | |
Credentials T.InMemoryCredentials.(new) | |
GetPin (\ [] (input)) | |
GoToTwitterAuthorization (\ [u:String] ($ Process.(Start u) ())) | |
).(let a | |
(= a.OAuthTwitter.OAuthConsumerKey "zap") |
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
Enumerable.(Range 0 100) | |
.(Select { | |
(== (% $0 15) 0).(cond | |
"Fizz Buzz" | |
(== (% $0 5) 0).(cond | |
"Fizz" | |
(== (% $0 3) 0).(cond | |
"Buzz" | |
$0.(ToString) | |
) |
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
Console.WriteLine(string.Join(" ", Enumerable.Range(0, 100) | |
.Select(n => n % 15 == 0 | |
? "Fizz Buzz" | |
: n % 5 == 0 | |
? "Fizz" | |
: n % 3 == 0 | |
? "Buzz" | |
: n.ToString() | |
) | |
)); |
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
{DispatchTypes.Method, "let", (e, s) => | |
e.Arguments[0] is VectorExpression | |
? new SymbolTable(s).Let(ns => ((VectorExpression) e.Arguments[0]).Elements | |
.SelectMany(_ => _.List(":").Let(l => l != null | |
? new [] { l.First(), Expression.Default(((TypeCandidateExpression) l.Last().Reduce(s)).ElectedType), } | |
: EnumerableEx.Return(_) | |
)) | |
.Share(_ => _.Zip(_, (i, v) => ((IdentifierExpression) i).Name.Let(n => | |
v.Reduce(ns).Apply(r => ns.Add(n, Expression.Variable(r.Type, n))) | |
))) |