simply scheme 第十五章 练习

15.1

(define (t num)

  (if(= num 0)

     '()

     (accumulate word(se (t (/(- num (remainder num 2))2))

         (remainder num 2)))))

15.2

(define (palindrome sent)

  (if(or(empty? sent)(=(count sent)1))

     #t

     (if(equal? (first(acc sent))(last(acc sent)))

        (palindrome (bf(bl(acc sent))))

        #f)))

 

(define (acc sent)

  (accumulate word sent))

15.3

(define (substrings wd)

  (if(empty? wd)

     '()

     (se (sub wd)(substrings (bf wd)))))

(define (sub wd)

  (if(=(count wd)1)

     wd

     (se (sub (bl wd))wd)))

15.4

(define (substring? w1 w2)

  (member? w1 (substrings w2)))

posted on 2010-07-14 21:48  草头菜  阅读(118)  评论(0编辑  收藏  举报

导航