Scheme

Haskell の sum と product を Scheme で実装

sum takes a list of numbers and returns their sum.product takes a list of numbers and returns their product. ghci> sum [5,2,1,6,3,2,5,7] 31 ghci> product [6,2,1,2] 24 ghci> product [1,2,5,6,7,9,2,0] 0 http://learnyouahaskell.com/starting-o…

空リストはアトムかリストか?

() もアトムの一種である。 とのことだが、Racketで > (list? '())とやると #t と評価される。空リストはアトムかリストか、結局どっちだ? ちなみにThe Little SchemerではS式がアトムかどうか判別する関数として (define (atom? x) (and (not (pair? x)) (…