lisp
読者の宿題、atom-countを書いてみた。 (defun atom-count (x) (cond ((atom x) 1) (t (atom-count2 x)))) (defun atom-count2 (x) (cond ((null x) 0) ((atom (car x)) (1+ (atom-count2 (cdr x)))) (t (+ (atom-count2 (car x)) (atom-count2 (cdr x))))))
読者の宿題、atom-countを書いてみた。 (defun atom-count (x) (cond ((atom x) 1) (t (atom-count2 x)))) (defun atom-count2 (x) (cond ((null x) 0) ((atom (car x)) (1+ (atom-count2 (cdr x)))) (t (+ (atom-count2 (car x)) (atom-count2 (cdr x))))))