Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure:使用不同的算术数重现匿名函数_Clojure_Arity - Fatal编程技术网

Clojure:使用不同的算术数重现匿名函数

Clojure:使用不同的算术数重现匿名函数,clojure,arity,Clojure,Arity,类似于,我想以不同的方式重现。但在我的例子中,我通过let定义函数,因为我想使用let(文件列表)中的另一个值而不传递它: (let [file-list (drive/list-files! google-drive-credentials google-drive-folder-id) download-file (fn ([name] (download-file ; <-- att

类似于,我想以不同的方式重现。但在我的例子中,我通过let定义函数,因为我想使用let(
文件列表
)中的另一个值而不传递它:

(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))))]
  ;; #
  )
(让[文件列表(驱动器/列表文件!谷歌驱动器凭据谷歌驱动器文件夹id)
下载文件(fn)
([姓名]
(下载文件;>文件列表)
(过滤器#(=(:原始文件名))
(姓名)
第一)]
(驱动器/下载文件!谷歌驱动器凭据文件)
(未找到fn))]
;; #
)

我收到以下错误:
线程“main”java.lang中出现异常。RuntimeException:无法解析symbol:在此上下文中下载文件

(let [download-file (fn download-file
                      ([name] (download-file name (fn ...))))
您还可以使用:


为了使异常错误消息更具可读性,我经常在内部函数名后面附加
-fn
,如下所示:

(let [download-file (fn download-file-fn [name] ...) ]
   <use download-file> ...)
(让[下载文件(fn下载文件fn[名称]…)]
...)
(let [download-file (fn download-file-fn [name] ...) ]
   <use download-file> ...)