Skip to content

Instantly share code, notes, and snippets.

View takeshik's full-sized avatar

Takeshi KIRIYA takeshik

View GitHub Profile
using System;
using System.Linq;
using System.Linq.Expressions;
class Program
{
static void Main(string[] args)
{
new [] {"foo", "", "bar", null, "baz", " "}
.Where(Invert<Func<String, Boolean>>(String.IsNullOrWhiteSpace))
// :Program.:Impl
internal static void <Main>:Impl()
{
File.ReadLines("a.log").ForEach(delegate(string $0)
{
Console.WriteLine($0);
});
}
var ws = new WebSocket('ws://localhost:3966');
ws.onmessage = function (ev) {
var e = JSON.parse(ev.data);
console.log(e);
};
ws.send(JSON.stringify({tabs: ['適当な流量のタブの名前']}));
@takeshik
takeshik / yacq-nodes-and-pattern-match.markdown
Created May 28, 2012 17:43
Yacq の式ノードとパターンマッチ

Yacq の式ノード

  • Yacq +

    Yacq の式ノード型階層の頂点

    • AmbiguousLambda

      曖昧な (型が推論される) ラムダ

using System;
using System.Linq;
using System.Reflection;
internal static class Program
{
private static void Main()
{
var asm = Assembly.Load("ClassLibrary1");
var type = asm.GetType("Class");
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace TrimStringTest
{
/// <summary>
private static IEnumerable<Expression> Unquote(Expression expression, SymbolTable symbols, Int32 level)
{
return (expression as ListExpression).Null(el => el[0].Id().Let(i => i == "quasiquote"
? Unquote(el[1], symbols, ++level)
: i == "unquote"
? EnumerableEx.Generate(
el,
_ => _ != null && _[0].Id() == "unquote",
_ => _[1] as ListExpression,
_ => _[1]
@takeshik
takeshik / quote-syntaxes.patch
Created April 22, 2012 03:18
support #' (quote), #` (quasiquote), #, (unquote) and #,@ (unquote-splicing) syntaxes
diff --git a/Yacq/LanguageServices/Reader.Defaults.cs b/Yacq/LanguageServices/Reader.Defaults.cs
index 594cd20..98ca331 100644
--- a/Yacq/LanguageServices/Reader.Defaults.cs
+++ b/Yacq/LanguageServices/Reader.Defaults.cs
@@ -222,9 +222,9 @@ namespace XSpect.Yacq.LanguageServices
var text =
Span(
from x in Chars.OneOf('\'', '\"', '`')
- let quote = x.Satisfy()
- from y in quote.Not().Right(Chars.Any()).Many().Select(_ => new String(_.ToArray()))
(load "cts:Inscribe.Storage")
(load "cts:Inscribe.Communication.Posting")
AccountStorage.Accounts.(ForEach (\ [a]
PostOffice.(UpdateTweet a "くるるたんの腎臓ペロペローーー!!!!!!")
PostOffice.(UpdateTweet a "くるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたんくるるたん")
PostOffice.(UpdateTweet a "ピャァァァァァァァァァァwwwwwwくるるたん腹パン腹パン!!!!")
PostOffice.(UpdateTweet a "くるるたんの脳みそ汁飲みたいです^^")
))
@takeshik
takeshik / conv.cs
Created February 2, 2012 22:24
Numeric Conversions
internal static Type ConvertNumericType(Type expressionType, Type expectedType)
{
var expectedType_ = Type.GetTypeCode(Nullable.GetUnderlyingType(expectedType) ?? expectedType);
switch (Type.GetTypeCode(Nullable.GetUnderlyingType(expressionType) ?? expressionType))
{
case TypeCode.Char:
switch (expectedType_)
{
case TypeCode.Char:
case TypeCode.UInt16: