Skip to content

Instantly share code, notes, and snippets.

View octarect's full-sized avatar
🔥
Incendiarism

Ryota Kota octarect

🔥
Incendiarism
  • Tokyo, JP
View GitHub Profile
(load "./p202-generic-alithmetic.scm")
(define (attach-tag tag-type contents)
(if (eq? tag-type 'scheme-number)
contents
(cons tag-type contents)))
(define (type-tag datum)
(cond ((number? datum) 'scheme-number)
((pair? datum) (car datum))
(else (error "Bad tagged datum -- TYPE-TAG" datum))))
@octarect
octarect / Gemfile
Last active August 27, 2017 13:11
collect images from inorimachi
# frozen_string_literal: true
source "https://rubygems.org"
gem "mechanize"
gem "nokogiri"
gem "tomlrb"
sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[+A](head:A, tail:List[A]) extends List[A]
object List {
def foldr[A,B](l: List[A], z: B)(f: (A, B) => B): B = l match {
case Nil => z
case Cons(h, t) => f(h, foldr(t, z)(f))
}
class Young
MAX = 2 ** 32 - 1
def initialize m, n, arr=[]
@bottom = m - 1
@right = n - 1
@tbl = Array.new m
m.times {|i| @tbl[i] = Array.new n, MAX }
arr.each {|x| insert x }
end
@octarect
octarect / command.rb
Last active December 19, 2015 04:25
nand2tetris_vm
module Command
C_NONE = 0
C_ARITHMETIC = 1
C_PUSH = 2
C_POP = 3
C_LABEL = 4
C_GOTO = 5
C_IF = 6
C_FUNCTION = 7
C_RETURN = 8
We couldn’t find that file to show.