simply scheme 第五章 練習

5.1 (1)(I me mine) (2)(is empty) (3) 1234 (4) (23 45) (5) "" (6) () (7) 6 (8) ("" "") (9) 2

 

5.2 

 

(define (f1 wd1 wd2)

  (sentence (bf wd1) (bf wd2)))

 

(define (f2 wd1 wd2)

  (sentence (bf wd1) (bl wd2) (word (first wd1) (last wd2))))

 

(define (f3 wd1 wd2)

  (se wd1 wd1))

 

(define (f4 wd1 wd2)

  (word (first (butfirst wd1)) (first (butfirst wd2))))

 

 

5.3 output: m and mezzanine

 

5.4 output: 4 and square

 

5.5 output: abc and (a b c)

 

5.6 輸出一樣

 

5.7 output: "" and ()

 

5.8 none

 

5.9 (matt wright) (brian harvey)

 

5.10 word returns word sentence returns sentence

 

5.11 the same as 5.10

 

5.12 

5.13 'banana quote

 

5.14 (define (third x)

  (first(butfirst(butfirst x))))

 

5.15 (define (first-two x)

  (word (first x)(first (butfirst x))))

 

5.16 (define (two-first x y)

  (word (first x)(first y)))

 

 (define (two-first-sent x)

  (word (first(first x))(first(first(butfirst x)))))

 

5.17 (define (knight x)

  (se 'Sir x))

 

5.18 error

 

5.19 (define (insert-and x)

  (se (butlast x) 'and (last x)))

 

5.20 (define (middle-names x)

  (butlast(butfirst x)))

 

5.21

 

(define (query x)

  (se (first (butfirst x)) (first x) (butfirst(butfirst x)) '?))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章