2010/04/29

TSS TLS atom?

無駄に複雑に書き直した話。

The Little Schemer, 4th Edition と The Seasoned Schemer に出てくる、atom?手続き。

(define (atom? a)
(and (not (pair? a))
(not (null? a))))
(define (atom? a)
(every (cut <> a)
(map (cut compose not <>)
`(,pair? ,null?))))
(define (atom? a)
(every (cut <> a)
(map complement
`(,pair? ,null?))))
view raw atom?.scm hosted with ❤ by GitHub

上が本の序文に記載されているもので、下が書き直したもの。
The Little Schemer, 4th EditionThe Seasoned Schemer

0 件のコメント:

コメントを投稿