Clojure中是否有阅读器宏或核心函数,与recur
类似,但可能使用非尾部位置?用于自定义递归函数的通用函数定义
例如,在这个递归函数
(defn insertR* [newkey oldkey l]
(cond
(empty? l) '()
(not (seq? (first l)))
(if (= (first l) oldkey)
(cons oldkey (cons newkey (insertR* newkey oldkey (rest l))))
(cons (first l) (insertR* newkey oldkey (rest l))))
:else
(cons (insertR* newkey oldkey (first l)) (insertR* newkey oldkey (rest l)))))
有一些通用的功能,我可以用它来调用本身,而不是调用insertR*
明确?
突出显示递归调用。我的意思是后者。 – 2011-05-17 17:40:36