csvファイルのカラムの要素による集計をするRubyスクリプト

住所録から市(区)毎の合計数を集計するRubyスクリプトのメモ。 csvファイルは、文字コードが utf-8 、改行コードが lf を想定している。 $KCODE = "UTF8" require & [...]…続きを読む

問題1.38、問題1.39 – SICP(計算機プログラムの構造と解釈)その20

問題1.38 (define (cont-frac n d k) (define (iter i) (if (= i k) (/ (n i) (d i)) (/ (n i) (+ (d i) (iter (+ i 1)) [...]…続きを読む

問題1.35、問題1.36、問題1.37 – SICP(計算機プログラムの構造と解釈)その19

問題1.35 (define tolerance 0.00001) (define (fixed-point f first-guess) (define (close-enough? v1 v2) (< (abs [...]…続きを読む

1.3.3一般的方法としての手続き(区間二分法による方程式の零点の探索) – SICP(計算機プログラムの構造と解釈)その18

1.3.3 一般的方法としての手続き 区間二分法による方程式の零点の探索 (define (search f neg-point pos-point) (let ((midpoint (average neg-point [...]…続きを読む

局所変数letの使い方、問題1.34 – SICP(計算機プログラムの構造と解釈)その17

局所変数 let の使い方 let は変数を特定の範囲内に束縛する。 変数の値は let の外側で計算される。 問題1.34 (define (f g) (g 2)) (f square) (square 2) (* 2 [...]…続きを読む

問題1.33 – SICP(計算機プログラムの構造と解釈)その16

問題1.33 まず再帰的プロセスのものを書く。 (define (filtered-accumulate combiner null-value filter-pre term a next b) (cond ((&gt [...]…続きを読む

問題1.32a、問題1.32b – SICP(計算機プログラムの構造と解釈)その15

問題1.32 a 再帰的プロセスの accumulate (define (accumulate combiner null-value term a next b) (if (> a b) null-value [...]…続きを読む

問題1.31a、問題1.31b – SICP(計算機プログラムの構造と解釈)その14

問題1.31 a sum 手続きとほぼ同じ形で表せる(+ が * になる)。 ただし、a > b の際の戻り値が1となる。 (define (product term a next b) (if (> a b [...]…続きを読む

問題1.30 – SICP(計算機プログラムの構造と解釈)その13

問題1.30 線形再帰の sum 手続き (define (sum1 term a next b) (if (> a b) 0 (+ (term a) (sum1 term (next a) next b)))) [...]…続きを読む

問題1.29 – SICP(計算機プログラムの構造と解釈)その12

問題1.27 パス 問題1.28 パス 問題1.29 うーん、Simpsonの公式を使った方が精度が落ちているような気がする… (define (cube x) (* x x x)) (define (inc [...]…続きを読む
Page 5 of 11« First...3456710...Last »
↑ページの先頭へ