Skip to content

Instantly share code, notes, and snippets.

View takahisa's full-sized avatar

Takahisa Watanabe takahisa

  • Cybozu, Inc
  • Tokyo, Japan
View GitHub Profile
@takahisa
takahisa / gist:1033860
Created June 19, 2011 07:20
パーサーテスト用の入力ファイル
module std {
def fib = 1 -> Int
=> 1
  def fib = 2 -> Int
=> 1
def fib = n:Int -> Int
=> fib(n-2) + fib(n-1)
}
module program {
@takahisa
takahisa / bf.txt
Created August 17, 2011 22:45
HeadacheによるBrain F*ckのソースコードだけどどっかの括弧が対応取れてなくてバグってる。あとジャンプ命令あたりも怪しい
let source : "+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.\0"
let item :
lambda n ->
lambda list ->
if ( = n 0 )
then head list
else item ( - n 1 ) ( tail list )
let state :
@takahisa
takahisa / gist:1160844
Created August 21, 2011 16:55
VBAで書いたBefungeインタプリタ
Option Explicit On
Dim sheet As Worksheet
Dim count As Long
Sub Main()
Dim cell As String
Dim x, y As Long
Dim a, b, c As Long
Dim align As Integer
@takahisa
takahisa / gist:1193486
Created September 4, 2011 20:47
HeadacheでFizzBuzz
let fizz_buzz : \n ->
let fizz_buzz : \i -> \n ->
( let m : ( + i 1 ) ->
( cond ( > i n ) ()
( cond ( = ( % i 15 ) 0 ) ( >>= ( puts "fizzbuzz" ) ( fizz_buzz m n ) )
( cond ( = ( % i 3 ) 0 ) ( >>= ( puts "fizz" ) ( fizz_buzz m n ) )
( cond ( = ( % i 5 ) 0 ) ( >>= ( puts "buzz" ) ( fizz_buzz m n ) )
( >>= ( puts i ) ( fizz_buzz m n ) ) ) ) ) ) ) -> fizz_buzz 1 n ;
// こんな感じのクラスを作って
abstract class Super<T> {
public abstract Super<U> Foo<U>(Func<T,U> map);
}
// Super<T>を継承したSub<T>を作って、それを実装する時
class Sub<T> : Super<T> {
   // ↓こうなるのを
public override Super<U> Foo<U>(Func<T,U> map) { ... }
@takahisa
takahisa / a.cs
Created November 2, 2011 11:49 — forked from takeshik/a.cs
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>(); }
class Parser
rule
target : unit
| { result = 0 }
unit : stat
| unit stat
stat : expr SEMICOLON
module Esolang
open System
open System.IO
open FParsec
open FParsec.CharParsers
open FParsec.Primitives
open FParsec.Error
type Pattern =
| As of Pattern * Pattern
@takahisa
takahisa / gist:1858379
Created February 18, 2012 09:11
YacqReader(Parseq版)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XSpect.Yacq.Expressions;
using Parseq;
using Parseq.Combinators;
Enumerator := Object clone do(
current := method(Exception raise("not implemented"))
moveNext := method(Exception raise("not implemented"))
reset := method(Exception raise("not implemented"))
)
Enumerable := Object clone do(
enumerator := method(Exception raise("not implemented"))
)