Re: S-s-s-serious performance bug with `map` laziness

2013-07-13 Thread Andy Fingerhut
I believe that what you are seeing, with up to 32 more elements being evaluated than is necessary to execute your code, is due precisely to chunked sequences, as returned by (range n), preserved by map, and I believe also for, doseq, and other Clojure functions and macros. Chunked sequences can ca

Re: S-s-s-serious performance bug with `map` laziness

2013-07-13 Thread Daniel Dinnyes
Seems these guys below have the same problem, and everyone thinks it is `apply` or `concat` to blame. One of the answerer even explains how apply is the issue, but in the reimplemented version of `mapcat` beside throwing out `apply` he does not use `map` either: http://stackoverflow.com/questio

S-s-s-serious performance bug with `map` laziness

2013-07-13 Thread Daniel Dinnyes
Hiya, check this code out guys: (defn point [x y] (println "x:" x "y:" y) [x y]) (defn gen-data [n m] (for [i (range n)] (for [j (range m)] (point i j (def data (apply concat (gen-data 100 100))) (nth data 5) "The output was the following:" "x: 0 y: 0 x: 0 y: 1 x: 0