Leiningen Uberjar is different from lein run

My application starts when I run it in clojure repl or using leiningen repl, but when I create a jar using uberjar and run the application, it only reads the first 2 records of my collection.

I tracked it to pmap, so I made the simplest possible use of pmap, and it became more robust. why is this work

(ns ktest.core (:gen-class)) (defn -main [] (println (pmap identity (range 20)))) 

but not this

 (ns ktest.core (:gen-class)) (defn -main [] (pmap #(println %) (range 20))) 
+4
source share
1 answer

you were bitten by a "lazy mistake." pmap creates a sequence that, when read, will calculate the results. when you run it with println , it reads the results to print them, thereby initiating an evaluation. In this case, you can fix it will be doall or dorun . If you only need side effects when printing, select dorun , if you need to do something with this result, select doall , which saves the results in memory.

 (dorun (pmap #(println %) (range 20))) 

multiple items are printed due to fragmented sequences . see this Jira question for details on pmap and chunked sequence .

+4
source

Source: https://habr.com/ru/post/1440165/


All Articles