类似于Clojure recur with multi-arity,我希望 recur 使用不同的 arity。但就我而言,我通过 let 定义函数,因为我想使用 let ( file-list
) 中的另一个值而不传递它:
(let [file-list (drive/list-files! google-drive-credentials google-drive-folder-id)
download-file (fn
([name]
(download-file ; <-- attempt to recur
name
(fn []
(throw
(ex-info
(str name " not found on Google Drive"))))))
([name not-found-fn]
(if-let [file (->> file-list
(filter #(= (:original-filename %)
name))
first)]
(drive/download-file! google-drive-credentials file)
(not-found-fn))))]
;; #
)
我收到此错误:Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: download-file in this context