我正在享受 clojure 的乐趣,并且想知道 _ 语法在函数参数向量中的作用。
例子:
(def available-processors
(.availableProcessors (Runtime/getRuntime)))
(prn "available processors: " available-processors)
(def pool
(Executors/newFixedThreadPool (+ 2 available-processors)))
(defn dothreads!
[func & {thread-count :threads exec-count :times :or {thread-count 1 exec-count 1}}]
(dotimes [t thread-count]
(.submit pool #(dotimes [_ exec-count] (func)))))
表格中的下划线是做什么的:
#(dotimes [_ exec-count] (func))