# jiacai2050/sicp

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (45 sloc) 2 KB

Mary Ann Moore `A1` Lorna `B1`
Colonel Downing `A2` Melissa `B2`
Mr. Hall `A3` Rosalind `B3`
Sir Barnacle `A4` Gabrielle `B4`
Dr. Parker `A5` XX `B5`

1. `(B2 A4)` 成立
2. `(By Ax)``x!=y`
3. `(B4 Ax)``(By A5)` 中，`x` = `y`

1. `(B4 Ax)``x` 的取值范围是`1``2``3`
2. `(By A5)``y` 的取值范围是`1``2``3`，由因为条件1，y 的值缩小到 `1``3`

``````; 这里假设 get-index 能返回父亲或女儿的下标
; 比如 (get-index 'A1)  ==> 1
(define (get-index s)
...)
(define (get-father p)
(define (get-daughter p)
(car p))

(define (pair-father)
(let ((p1 ('B1 (amb 'A2 'A3 'A5)))
(p2 ('B2 A4))
(p3 ('B3 (amb 'A1 'A2 'A5)))
(p4 ('B4 (amb 'A1 'A2 'A3)))
(p5 ('B5 (amb 'A1 'A2 'A3))))
(require (distinct? (get-index (get-father p1))
(get-index (get-father p2))
(get-index (get-father p3))
(get-index (get-father p4))
(get-index (get-father p5))))
(require (distinct? (get-index (get-daughter p1))
(get-index (get-daughter p2))
(get-index (get-daughter p3))
(get-index (get-daughter p4))
(get-index (get-daughter p5))))
(get-index (get-father p1))))
``````