再帰

うーむ、CommonLispではさくっと動くものがClojureだと動かない・・・

user> (defn count-anywhere [item tree]
	    "count the times item appears anywhere within tree."
	    (cond (= item tree) 1
		  (not (seq? tree)) 0
		  :else (+ (count-anywhere item (first tree))
			   (count-anywhere item (rest tree)))))

再帰する関数がStackOverflowになりますなぁ。

と思っていたら・・・
nokturnalmortumさんありがとうございます!

user> (defn count-anywhere [item tree]
	    (cond (= item tree) 1
		  (not (seq? tree)) 0
		  (empty? tree) 0
		  :else (+ (count-anywhere item (first tree))
			   (count-anywhere item (rest tree)))))
#'user/count-anywhere
user> (count-anywhere 'a 'a)
1
user> (count-anywhere 'a '(a b))
1
user> (count-anywhere 'a '(a ((a) b) b))
2

「実用CommonLisp」で

((atom tree) 0)

としていたところを

(not (seq? tree)) 0

ってやったのがまずかった。