Skip to content

Instantly share code, notes, and snippets.

View pasberth's full-sized avatar

pasberth pasberth

View GitHub Profile
@pasberth
pasberth / lazyk.coffee
Last active December 28, 2015 04:49
Lazy K in CoffeeScript
lazy = (x) -> () -> x
thaw = (x) -> x()
app = () -> [].slice.call(arguments, 0).reduce (x, y) -> () -> thaw(x)(y)
S = (x) -> (y) -> (z) -> thaw app(x, z, app(y, z))
K = (x) -> (y) -> thaw x
I = (x) -> thaw x
parseLazyK = (source) ->
stack = [[]]
@pasberth
pasberth / README.md
Created October 25, 2013 03:19
TypedCoffeeScript
$ ./bin/coffee --js < a.coffee

Cannot read property 'args' of undefined

USE_OCAMLFIND = true
OCAMLPACKS[] =
llvm
FILES[] =
types
lambda
parser
lexer
@pasberth
pasberth / a.bash
Last active December 26, 2015 10:39
#! bin/bash
MANSECT="1 2 3 4 5 n"
for i in $MANSECT
do
echo 'aaa'
done
# aaa
# aaa
# aaa
@pasberth
pasberth / a.hs
Created October 22, 2013 13:18
型レベルで計算するやつ
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
@pasberth
pasberth / main.html
Created October 11, 2013 12:51
Toggle するやつ
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script>
jQuery(function ($) {
$(".bg").bind("click", function () {
$(".fg").add("#show").add("#hide").toggleClass("showing hiding");
});
(< let %N (using qualified data.church.number)
`. let %B (using qualified data.church.boolean)
`in
#(< let %3 (N #succ (N #succ (N #succ (N #$0))))
`. let %5 (N #succ (N #succ (N #succ (N #succ (N #succ (N #$0))))))
`. let %church-nat->js-int (%n #(n ($+ "1") "0"))
`. let %IF (%cond (%then (%else #(cond then else))))
`. let %EQ (%n (%m #(B #and (N #zero? (N #sub n m)) (N #zero? (N #sub m n)))))
`in #(< let %15 (N #mul $3 $5)
@pasberth
pasberth / fizzbuzz.cpp
Created October 1, 2013 13:54
template で fizzbuzz
#include <string>
#include <iostream>
template <bool cond>
struct print_if
{
static void run(std::string msg) {}
};
@pasberth
pasberth / りよのじ先生の次回作.md
Last active December 23, 2015 22:29
りよのじ先生の次回作です

(1)

 俺はごく普通の高校2年生。強いて違う所をあげるとすれば絵を描くのが好きだってことかナー。名前はりよのじ。 毎日、朝早く起きては、同じバスに乗り、同じ高校に通って、同じような問題を解くのだ。たまの日曜日に 絵を描くのも、もはや繰り返しのひとつに過ぎない。要するにくだらない人生である。

 今日も夜遅くに帰宅し、両親のいないキッチンで晩飯をとった。代わり映えのない1日の終わりだった。 それから、俺は風呂の支度をし、沸くまで待つ事にして、自室に戻った。すると

「きゃー!」

@pasberth
pasberth / FizzBuzz.hs
Created September 6, 2013 14:58
Template Haskell でコンパイル時 FizzBuzz
{-# LANGUAGE TemplateHaskell #-}
module FizzBuzz where
import Language.Haskell.TH
fizzbuzz :: Int -> ExpQ
fizzbuzz 0 = [| putStrLn "FizzBuzz" |]
fizzbuzz n = appE (appE (varE (mkName ">>"))
(fizzbuzz (n - 1)))