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