Skip to content

Instantly share code, notes, and snippets.

View takeshik's full-sized avatar

Takeshi KIRIYA takeshik

View GitHub Profile
<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>
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();
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);
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]