simply scheme 第十一章 練習

<!-- @page { margin: 2cm } PRE.western { font-family: "DejaVu Sans Mono", monospace } PRE.cjk { font-family: "AR PL UKai CN", monospace } PRE.ctl { font-family: "DejaVu Sans Mono", monospace } P { margin-bottom: 0.21cm } -->

11.1

(define (downup4 wd)

  (se wd

      (bl wd)

      (bl (bl wd))

      (first wd)

      (bl (bl wd))

      (bl wd)

      wd))

11.2

(define (count-ums sent)

  (if(empty? sent)

     0

     (if(equal? 'um (first sent))

     (+ 1(count-ums(bf sent)))

     (count-ums(bf sent)))))

11.3

(define (phone-unspell wd)

  (if(empty? wd)

     '()

     (accumulate word(se (unspell-letter(first wd))

         (phone-unspell (bf wd))))))

11.4

Marilu Henner

11.5

(define (initials sent)

  (if(empty? sent)

     '()

     (se (first(first sent)) (initials (bf sent)))))

11.6

(define (countdown num)

  (if(equal? num 0)

     'BLASTOFF

     (se num (countdown (- num 1)))))

11.7

(define (copies num wd)

  (if(equal? num 0)

     '()

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