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.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Net; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace TinyTweet |
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 static Attribute[] GetAttributes(Expression expr) | |
{ | |
switch (expr.NodeType) | |
{ | |
case ExpressionType.MemberAccess: | |
return Attribute.GetCustomAttributes(((MemberExpression) expr).Member); | |
case ExpressionType.Invoke: | |
return Attribute.GetCustomAttributes(((MethodCallExpression) expr).Method); | |
case ExpressionType.Index: | |
return Attribute.GetCustomAttributes(((IndexExpression) expr).Indexer); |
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 TypeName | |
{ | |
public String Namespace { get; set; } | |
public String[] HierarchicalNames { get; set; } | |
public override String ToString() | |
{ | |
return String.Join("+", this.HierarchicalNames); | |
} | |
} |
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); | |
} |