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 IEnumerable<Expression> TraverseImpl(Expression expression) | |
{ | |
switch (expression.GetType().Name) | |
{ | |
case "BinaryExpression": | |
return (expression as BinaryExpression).Let(e => new [] | |
{ | |
e.Conversion, | |
e.Left, | |
e.Right, |
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 dic = Enumerable.Range(char.MinValue, char.MaxValue) | |
.Select(i => | |
{ | |
Console.Clear(); | |
Console.CursorTop = 0; | |
Console.CursorLeft = 0; | |
Console.Write((char) i); | |
return Console.CursorTop != 0 || Console.CursorLeft != 1 | |
? Tuple.Create(i, Console.CursorLeft) | |
: null; |
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 cp932CharWidths = new Dictionary<Char, Byte>() | |
{ | |
{'\u0007', 0}, | |
{'\u0008', 0}, | |
{'\u0009', 8}, | |
{'\u000A', 0}, | |
{'\u000D', 0}, | |
{'\u00A2', 2}, | |
{'\u00A3', 2}, | |
{'\u00A7', 2}, |
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
void Main() | |
{ | |
Make.Fix<int>(f => n => n < 2 ? 1 : f(n - 1) * n)(5).Dump(); // 120 | |
} | |
public class Make | |
{ | |
public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> func) { return Fun<T>.Fix(func); } | |
public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> func, T dummy) { return Fun<T>.Fix(func); } | |
private static class Fun<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
public class ColumnData | |
{ | |
public string Track; | |
public string Follow; | |
public string AccountName; | |
public string Tille; | |
public string Image; | |
public Column.StartType ColumnType; | |
public ColumnData Set(string _AccountName, string _Title, string _Track, string _Follow, Column.StartType Start) | |
{ |
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
Expression<Func<int, int, bool>> expr1 = (x, y) => x * y < 20; | |
Expression<Func<int, int, bool>> expr2 = (x, y) => x + y == 8; | |
Expression<Func<int, int, bool>> expr = CombineLambda(expr1, expr2); | |
Console.WriteLine(expr.Compile()(3, 5)); // True | |
public static Expression<TDelegate> CombineLambda<TDelegate>(Expression<TDelegate> left, Expression<TDelegate> right) | |
{ | |
// TODO: ここを埋めたい! | |
throw new NotImplementedException(); |
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
public IEnumerable<Expression> ReduceYield(SymbolTable symbols, Type expectedType) | |
{ | |
Expression expression = this; | |
while (true) | |
{ | |
Expression result; | |
if (expression is YacqExpression) | |
{ | |
result = ((YacqExpression) expression).ReduceOnce(symbols, expectedType); | |
} |
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
<expression z:Id="i1" i:type="Block" xmlns="http://yacq.net/schema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/"> | |
<Variables> | |
<Parameter z:Id="i2"> | |
<Type z:Id="i3"> | |
<Assembly z:Id="i4" /> | |
<Name>System.Int32[]</Name> | |
</Type> | |
<Name>a</Name> | |
</Parameter> | |
</Variables> |
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
Expression expr = YacqServices.Parse("Int32.(Parse '123').(ToString 'x2')"); | |
SerializedExpression serializedExpr = YacqExpression.Serialize(expr); | |
var dumpedString = serializedExpr.SaveText(); | |
SerializedExpression deserializedExpr = YacqExpression.LoadText(dumpedString); | |
expr = deserializedExpr.Reduce(); |
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
internal static Node Serialize(Expression expression) | |
{ | |
switch (expression.NodeType) | |
{ | |
case ExpressionType.Add: | |
return Add((BinaryExpression) expression); | |
case ExpressionType.AddChecked: | |
return AddChecked((BinaryExpression) expression); | |
case ExpressionType.And: | |
return And((BinaryExpression) expression); |