■
「X51.ORG」がGyaoで番組になった - GIGAZINE
たまらないなぁ・・・
*18.8.2-4
久しぶりになってしまいました。
p250くらいまでやっとこさ辿りつきました。
あー、滅茶苦茶楽しくなってきました(理解度とは比例せず)。。
(define (list=? a-list another-list) ;;17.8.2 (cond ((and (cons? a-list) (empty? another-list)) false) ((and (empty? a-list) (cons? another-list)) false) (else (or (and (empty? a-list) (empty? another-list)) (or (= (first a-list) (first another-list)) (list=? (rest a-list) (rest another-list))))))) (define sym-list=? ;;17.1.3 (lambda (a-list another-list) (cond ((empty? a-list) (empty? another-list)) ((cons? a-list) (and (cons? another-list) (and (symbol=? (first a-list) (first another-list)) (sym-list=? (rest a-list) (rest another-list)))))))) (define contains-same-numbers ;;17.8.4 (lambda (a-lon another-lon) (cond ((empty? a-lon) true) ((and (empty? a-lon) (cons? another-lon)) false) ((and (cons? a-lon) (empty? another-lon)) false) ((find-n (first a-lon) another-lon) (contains-same-numbers (rest a-lon) another-lon))))) (define find-n (lambda (n lon) (cond ((empty? lon) false) ((= n (first lon)) true) (else (find-n n (rest lon))))))
昨日は飲み会があった。
いろんな人がいていろんな人の話を聞けて本当に充実していた。
参加されていた方たちはみんな人間が深くて自分もこうありたいなと改めて思ったりもした。
そういう人たちが周りにいるということは本当に幸せかもしれない。
自分がどうやったら慣れるか今はわからないけれど長いスパンでこのことを考えて行こうと思った。
Exercises17.1.2
今月に入って失速気味だったのですが一問解けたのでメモ。
(define LOS '(a b c)) (define LON '(1 2)) (define (cross alon1 alon2) ;;引数にリストを二つとって全部の組み合わせを書き出す関数 (cond ((empty? alon1) empty) (else (append (cross-aux (first alon1) alon2) (cross (rest alon1) alon2))))) (define (cross-aux n alon2) (cond ((empty? alon2) '()) (else (cons (list n (first alon2)) (cross-aux n (rest alon2)))))) (cross LOS LON) evaluates to ; (list (list 'a 1) (list 'a 2) (list 'b 1) (list 'b 2) (list 'c 1) (list 'c 2))
最近たべたタコスはまさに絶品だったので自分の中のメキシコ値が急上昇しています。
(HTDP)<この文字がどうもタコスっぽいと思のは自分だけでしょうか?
Exercises15.1.2
よし!来た電車の中で思いついた考え方でそれっぽいのが出てきた予感。
条件
・引数にとった親自身が青い目をしていた場合は0
・青い目をした人がいなかった場合はfalseを返す
---------------- family tree---------------------- (define-struct parent (children name date eyes )) ;;youngest Gneneration (define Gustav (make-parent empty 'Gustav 1998 'black)) (define Fred&Eva (list Gustav)) ;;children of Fred&Eva ;;Middle Generation (define Adam (make-parent empty 'Adam 1950'yellow)) (define Dave (make-parent empty 'Dave 1955 'black)) (define Eva (make-parent Fred&Eva 'Eva 1955 'brown)) (define Fred (make-parent Fred&Eva 'Fred 1966 'pink)) (define Carl&Bettina (list Adam Dave Eva)) ;; oldest Generation (define Carl (make-parent Carl&Bettina 'Carl 1926 'green)) (define Bettina (make-parent Carl&Bettina 'Bettina 1926 'green)) -----------------Exercises------------------------- (define (blue-eyed-descendant? a-parent) ;;引数にとった親に青い目をした子供がいるか調べる関数 (cond ((symbol=? (parent-eyes a-parent) 'blue) true) (else (blue-eyed-children? (parent-children a-parent))))) (define (blue-eyed-children? aloc) (cond ((empty? aloc) false) (else (cond ((blue-eyed-descendant? (first aloc)) true) (else (blue-eyed-children? (rest aloc))))))) (define (how-far-removed a-parent) ;;青い目をした人が何世代目か調べる関数 (cond ((not (blue-eyed-descendant? a-parent)) false) ((symbol=? (parent-eyes a-parent) 'blue) 0) (else (how-far-children? (parent-children a-parent))))) (define (how-far-children? loc) ;;子のリストを受け取る (cond ((empty? loc) 0) ((blue-eyed-descendant? (first loc)) (+ 1(how-far-children? (parent-children (first loc))))) (else (how-far-children? (rest loc))))) -----------------test---------------------- (how-far-removed Carl) evaluates to : 2 (how-far-removed Gustav) evaluates to : 0
それっぽい答えは出ているものの本当に正しいかもう少し考えてみないと
あと無駄なことしている可能性も大