(defun count-tf (ql hmtf) (cond ( (and (null ql) (= hmtf 0)) t ) ( (and (null ql) (not (= hmtf 0))) nil ) ( (eq (car ql) 'tf) (count-tf (cdr ql) (- hmtf 1)) ) ( t (count-tf (cdr ql) hmtf) ) ) ) (defun test-count-tf () (setq rtn (list (count-tf '() 0) ; Expect t (count-tf '(tf) 1) ; Expect t (count-tf '(tf tf) 2) ; Expect t (count-tf '(tf tf tf) 3) ; Expect t (count-tf '(tf x tf tf) 3) ; Expect t (count-tf '(tf tf x tf) 3) ; Expect t (count-tf '(x tf tf x tf x) 3); Expect t (count-tf '(x tf tf x tf x x x x x x x x x x x x x x tf) 4); Expect t (count-tf '() 1) ; Expect nil (count-tf '(tf) 2) ; Expect nil (count-tf '(tf tf) 3) ; Expect nil (count-tf '(tf tf tf) 4) ; Expect nil (count-tf '(tf x tf tf) 4) ; Expect nil (count-tf '(tf tf x tf) 4) ; Expect nil (count-tf '(x tf tf x tf x) 4); Expect nil (count-tf '() -1) ; Expect nil (count-tf '(tf) 0) ; Expect nil (count-tf '(tf tf) 1) ; Expect nil (count-tf '(tf tf tf) 2) ; Expect nil (count-tf '(tf x tf tf) 2) ; Expect nil (count-tf '(tf tf x tf) 2) ; Expect nil (count-tf '(x tf tf x tf x) 2); Expect nil (count-tf '() 1) ; Expect nil (count-tf '() 2) ; Expect nil (count-tf '() 100000) ; Expect nil (count-tf '(tf) 0) ; Expect nil (count-tf '(tf) 2) ; Expect nil )) ) (test-count-tf)