Skip to content

Instantly share code, notes, and snippets.

@monmon
monmon / q3.1.scm
Last active December 17, 2015 05:39
sicp 3章 問題3.4 まで。2013-05-13 担当分。
; 初期値を受け取り、それを内包し、あとは
; "常に「足す数」を渡すと内包されている総数に足すlambda"
; を作って返せばよい
(define (make-accumulator total)
(lambda (addends)
(set! total (+ total addends))
total))
(use gauche.test)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfgfI6FSrEJepjgZPHFen3CtIi1rilee/IB3Mh5P/c8MlKAv6wePlJGAXunrg91BWUqZfZG7cgUSOWYjjr0DjnQkcw3qDjGUJ5FHh8L8bcpFPgg0Tluml3FQH3jQgz/8OX1LGF5wJUMMlHTk8AkmesxKLXv+KjEA/8UpC/DF+F963yWaV/yuvrnOX0eZCfXMJP+gbfPHW+RT8c6CaZISB7krZGfnwGqObENoFTaIeadcU2xTVYptcVduJ96gryWsWom7UEvf8cwELjDGA9boLiBR0hOSLJ4OTbbF5xogtmxEI8ljgFMfYNKK2kBNweKuw8FJ5FO8D5rSay6Ry05TI3 lesamoureuses@gmail.com
@monmon
monmon / q2.75.scm
Last active December 14, 2015 03:59
sicp p.109 メッセージパッシング から p.113 問題2.80 まで。2013-02-26 担当分。
(define (make-from-mag-ang r a)
(define (dispatch op)
(cond ((eq? op 'real-part) (* r (cos a)))
((eq? op 'imag-part) (* r (sin a)))
((eq? op 'magnitude) r)
((eq? op 'angle) a)
(else
(error "Unknown op -- MAKE-FROM-REAL-IMAG" op))))
dispatch)
@monmon
monmon / id_rsa.yapcasia.pub
Created February 18, 2013 04:34
公開鍵的なやつ
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCl/gBStVjgW8IBEFxXXWvajjWpPC9xhoBXw4PN3YMd0109QRG7LDSRg5nVUNgxHGOXfLsgDKdT7GuH3HvXpn/wgi12Imu/I+NA6IJpMZqj1HLfs2JsunbqyRzDbConXjIR67FzyifnIESO6KmgAQCnTrM5f5IcLLUKSsAuskCbD3ZS78CHwgHXhwcYG+t2x29chcXyG6T8ypyxGFJS75IE7NfAtdkDPTMJCV2gsaGA9YLIn3Wq74FXdSzVIjCHF4zxQhsL2rnO0YBdsJZZ4HObSneQW4yy67x7IyT29G5PV1xQIV28dSpV7DdTQH2De6JLySmyerRofgBfBPIBJjx7 lesamoureuses@gmail.com
@monmon
monmon / gist:4159948
Created November 28, 2012 08:46
SICP q2.41
; 1 <= k < j < i <= n
;
; e.g.)
; s = 6
; 1 + 2 + 3 = 6
;
; s = 7
; 1 + 2 + 4 = 7
;
; s = 8
@monmon
monmon / gist:4159942
Created November 28, 2012 08:44
SICP q2.40
; まずp.71-72で以下のことまでは学習済み
(define nil '())
(define (square x) (* x x))
(define (divides? a b)
(= (remainder b a) 0))
(define (smallest-divisor n)
(find-divisor n 2))
(define (find-divisor n test-divisor)
(cond ((> (square test-divisor) n) n)
@monmon
monmon / gist:4057260
Created November 12, 2012 03:01
SICP q2.39
(define nil '())
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
(define fold-right accumulate)
(define (fold-left op initial sequence)
@monmon
monmon / gist:4057259
Created November 12, 2012 03:00
SICP q2.38
(define nil '())
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
(define fold-right accumulate)
(define (fold-left op initial sequence)
@monmon
monmon / gist:4057257
Created November 12, 2012 02:59
SICP q2.37
(define nil '())
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
(define (accumulate-n op init seqs)
(if (null? (car seqs))