【发布时间】:2015-06-09 07:19:12
【问题描述】:
(defun count-sub (str pat)
(loop with z = 0 with s = 0 while s do
(when (setf s (search pat str :start6 s))
(incf z) (incf s (length pat)))
finally (return z))))
是的,我有这段代码用于计算子字符串,但它一次只需要子字符串输入,我如何让它接受更多输入?
即所以输入会是这样的:
(count-sub "abcde" "a" "d" "e" "c")
而不仅仅是: (count-sub "abcd" "a")
【问题讨论】:
-
(count-sub "abcde" "a" "b")不等于(+ (count-sub "abcde" "a") (count-sub "abcde" "b"))吗?
标签: lisp