Skip to content

Instantly share code, notes, and snippets.

@krtx
krtx / snum.ml
Created March 16, 2014 06:55
surreal number implementation from On Numbers and Games
type snum = snums * snums
and snums = Nil | Cons of (snum * snums)
let zero = (Nil, Nil)
let one = (Cons (zero, Nil), Nil)
let mone = (Nil, Cons (zero, Nil))
let half = (Cons (zero, Nil), Cons (one, Nil))
let two = (Cons (one, Nil), Nil)
let rec map f = function
{
"1. Nature": {
"Weather and landscape symbols": {
"BLACK SUN WITH RAYS": "☀",
"CLOUD": "☁",
"UMBRELLA WITH RAIN DROPS": "☔",
"SNOWMAN WITHOUT SNOW": "⛄",
"HIGH VOLTAGE SIGN": "⚡",
"CYCLONE": "🌀",
"FOGGY": "🌁",
@krtx
krtx / Bisim.agda
Last active August 29, 2015 14:07
strong bisimulation is equivalence
module Bisim where
open import Data.Nat
open import Data.List
open import Data.Product using (∃; _×_; _,_; proj₁; proj₂)
open import Relation.Binary using (IsEquivalence)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
@krtx
krtx / test-ex1.3.scm
Created October 20, 2014 01:28
test for ex 1.3
(use gauche.test)
(test-start "test")
;; insert here
(define target PROGRAM-NAME)
(define (right a b c)
(let ((l (sort (list a b c) >)))
(let ((x (list-ref l 0))
@krtx
krtx / Ackerman.agda
Created November 3, 2014 02:45
SICP Exercise 1.10.
module Ackerman where
open import Data.Empty
open import Data.Nat
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
A : ℕ → ℕ → ℕ
A _ 0 = 0
@krtx
krtx / classic.agda
Last active August 29, 2015 14:10
classical logic
module classic where
open import Level
open import Relation.Nullary
open import Data.Empty
open import Data.Sum
open import Data.Product
-- peirce : ∀ {a b} (P : Set a) (Q : Set b) → Set (a ⊔ b)
module implicationallogic where
module Example where
postulate
Person : Set
john : Person
mary : Person
IsStudent : Person → Set
@krtx
krtx / mode-line.el
Created November 3, 2012 20:22
emacs mode-line
;;; red
;; (defconst color1 "#FF6699")
;; (defconst color3 "#CDC0B0")
;; (defconst color2 "#FF0066")
;; (defconst color4 "#CDC0B0")
;;; green
;; (defconst color1 "#66FF99")
;; (defconst color3 "#E1FFCC") ;; active mode-line
;; (defconst color2 "#00FF66")
@krtx
krtx / langrid.rb
Created November 4, 2012 20:58
langrid scraper
# coding: utf-8
# 日本語でやった人の日本語のデータと、
# 英語でやった人の英語のデータを取得する
# データは打ち込んだ文(表示されてるやつ)と
# 折り返し翻訳されたものの2つ
# language = 'ja'
# $ ruby langrid.rb > ja
# language = 'en'
@krtx
krtx / langrid2.rb
Created November 4, 2012 22:08
langrid scraper for back-translation
# coding: utf-8
require 'watir'
require 'pp'
# !!! EDIT HERE !!!
userid = ''
password = ''
language = 'ja' # 'ja' or 'en'
topic_id =