I am working through the joy of clojure and am wondering what the _ syntax does in a functions argument vector.
Example:
(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)))))
What is the underscore doing in the form:
#(dotimes [_ exec-count] (func))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…