This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<Star> stars = new ArrayList<Star>(); | |
ArrayList<Crystal> snow = new ArrayList<Crystal>(); | |
void setup() { | |
size(800, 600); | |
colorMode(HSB, 360, 1.0, 1.0, 1.0); | |
for (int i = 0; i < 30; i++) { | |
stars.add(new Star(random(width), random(0.7 * height), 30)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; Sieve of Eratosthenes | |
;;;; | |
(require srfi/2) ; and-let* | |
(require srfi/4) ; homogenous numeric vector | |
(require srfi/42) ; list comprehension | |
;;;; | |
;;;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; 自然数の符号化 | |
;;;; ツェルメロ (Zermelo) による方法 | |
;;;; | |
;;;; ノイマンの方式と比べると,順序の判定をするのに減算が必要なところが不便である。 | |
;;;; | |
(define (succ x) | |
(list x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; Primitive Recursive Functions: | |
;;;; | |
;;;; ペアノの公理を満たす自然数から,原始再帰関数を使って算術演算を定義したり, | |
;;;; 原始再帰的でない Hyper演算子や Ackermann 関数を定義する。 | |
;;;; | |
;;;; | |
;;;; Peano Axiom: | |
;;;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; little endian binary list style | |
;;;; | |
(define (succ xs) | |
(cond [(null? xs) (cons 1 xs)] | |
[(= (car xs) 1) (cons 0 (succ (cdr xs)))] | |
[else (cons 1 (cdr xs))])) | |
(define zero '()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; s_0 = 0 | |
;;;; s_1 = 1/2 | |
;;;; s_2 = 1/2 + 1/4 = 3/4 | |
;;;; s_3 = 1/2 + 1/4 + 1/8 = 7/8 | |
;;;; ... | |
;;;; s_n = 1/2 + 1/4 + ... + 1/2^n = (1-2^n)/2^n | |
;;;; | |
;;;; この s_n で自然数 n を表すことにするというもの。 | |
;;;; s_ω = 1 となって無限の順序数を考察するのに直観が働きやすいことから,自然数のモデルの例の1つとしてしばしば挙げられる。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; Church encoding | |
;;;; | |
;;;; ラムダ計算で自然数を符号化する方法 | |
;;;; | |
;;;; 基本的アイディア: | |
;;;; one(f, x) = f(x) | |
;;;; two(f, x) = f(f(x)) | |
;;;; three(f, x) = f(f(f(x))) | |
;;;; ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; 自然数の符号化 | |
;;;; ノイマン・スタイル | |
;;;; | |
;;;; 符号化した式が爆発して大変だが,これは集合での符号化を目的に考案されたものだから。 | |
;;;; 集合では { x, x } = { x } なので,前者後者が区別されるような工夫が必要とされた。 | |
;;;; | |
(define (succ x) | |
(cons x x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; 自然数の符号化 | |
;;;; s の個数で自然数の値を表す | |
;;;; 空リストは 0を表す | |
;;;; | |
(define (succ x) (cons 's x)) | |
(define zero '()) | |
(define one (succ zero)) ; => (s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; 自然数を評価可能な S式で符号化する | |
;;;; | |
(define (succ n) (list 's n)) | |
(define zero 0) | |
(define one (succ zero)) ; => (s 0) | |
(define two (succ one)) ; => (s (s 0)) | |
(define three (succ two)) ; => (s (s (s 0))) |