Completed
Details
Details
Assignee
Unassigned
UnassignedReporter
Leon Grapenthin
Leon GrapenthinApproval
Ok
Patch
Code and Test
Priority
Affects versions
Fix versions
Created June 19, 2015 at 4:48 PM
Updated September 14, 2018 at 10:21 PM
Resolved September 14, 2018 at 10:21 PM
(def x (partition-by zero? (range))) (first x) ;-> (0) (first (second x)) ;-> infinite loop
The reason is that partition-by counts and thus realizes each current partition to call itself recursively.
It seems like unexpected behavior, since the user may not intend to realize the entire partition.
Approach: Change from using seq to lazy-seq in its last line
Patch: clj-1764.patch
Screened-by: Alex Miller - I did a perf check too and seemed to be about the same, possibly even faster on average (gc effects mean there is a lot of deviation).
(def r (range 100000)) (dotimes [_ 20] (time (count (partition-by odd? r))))