Skip to content

Instantly share code, notes, and snippets.

View monmon's full-sized avatar
🌴
On vacation

monmon

🌴
On vacation
View GitHub Profile
@monmon
monmon / gist:4057254
Created November 12, 2012 02:59
SICP q2.36
(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))
@monmon
monmon / gist:4057253
Created November 12, 2012 02:58
SICP q2.35
(define nil '())
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
; 2.2.2
(define (count-leaves x)
@monmon
monmon / gist:3786274
Created September 26, 2012 05:26
SICP q1.46
; p.13 1.1.7 sqrt
(define (sqrt x)
(sqrt-iter 1.0 x))
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter (improve guess x)
x)))
@monmon
monmon / gist:3786271
Created September 26, 2012 05:25
SICP q1.45
; p.41のcube-rootを参考にコピペ
(define (fixed-point f first-guess)
(define tolerance 0.00001)
(define (close-enough? v1 v2)
(< (abs (- v1 v2)) tolerance))
(define (try guess)
(let ((next (f guess)))
(if (close-enough? guess next)
next
@monmon
monmon / gist:3786269
Created September 26, 2012 05:25
SICP q1.44
; たとえば
; f(0) = 1.0
; f(1) = 3.0
; f(2) = 9.0
; f(3) = 27.0
; f(4) = 81.0
; のとき
; (smooth(f))(1) = 4.333
; (smooth(f))(2) = 13.0
; (smooth(f))(3) = 39.0
@monmon
monmon / gist:3786268
Created September 26, 2012 05:24
SICP q1.43
; たとえば
; f(f(x))
; はq1.42のcomposeを使って
; ((compose f f) x)
; とかける
;
; ここでf(f(x))をg(x)とする
;
; f(f(f(x)))
; は
@monmon
monmon / gist:3786266
Created September 26, 2012 05:24
SICP q1.42
; p.39の脚注58より
; x |-> f(g(x))
; は
; (lambda (x) (f (g x)))
(define (compose f g)
(lambda (x) (f (g x))))
@monmon
monmon / gist:3748206
Created September 19, 2012 07:35
NGVaryingGridViewでサンプルコード勉強会

使い方

概要

  • TableViewと同じようにgridViewDelegateを実装してcellを作る
    • @required rectsForCellsInGridView:
  • cellの位置情報を含んだCGRectのNSArrayを作り、それを返す
@monmon
monmon / gist:3141604
Created July 19, 2012 08:35
Sparrowで使われているoverlayのmenuサンプルであるMHTabBarController