;; learning The Little Schemer (def car first) (def cdr rest) (def cons clojure.core/cons) (def eq? =) (def list? clojure.core/list?) (defn atom? [x] (not (list? x))) (defn s-exp? [x] (or (atom? x) (list? x))) (defn null? [x] (if (atom? x) (car x) ;raise a exception (and (list? x) (empty? x))))
抛出异常的地方是为了保持“未定义”语义,即书中说到的 “you cannot do this”
用Clojure学习The Little Schemer时的一些基本函数定义
时间: 2024-10-04 02:54:23