P54A: 二分木であることを確認
L-99もP46以降からPrologの問題そのままになってきた。
取りあえず、この辺りでいったん終了。
PAIP本でPrologの実装を調べてくるか。
;; P54A (defun istree (tree) (cond ((null tree) t) ((not (consp tree)) nil) ((not (= (length tree) 3)) nil) (t (and (istree (second tree)) (istree (third tree)))))) (istree '(a (b nil nil) nil)) ;; => T (istree '(a (b nil nil))) ;; => NIL (istree '(a (b nil (c nil)) nil)) ;; => NIL