Re: Why does the first expression take much longer

2014-07-12 Thread James Reeves
You're right; now that I look more closely, there is a difference between the two expressions. The split-with function is literally a combination of take-while and drop-while, like so: (defn split-with [pred coll] [(take-while pred coll) (drop-while pred coll)]) This is important because it m

Re: Why does the first expression take much longer

2014-07-12 Thread Cecil Westerhof
2014-07-12 11:56 GMT+02:00 James Reeves : > The JVM optimises sections of code that are frequently executed, so the > second expression benefits from the optimisation that happens during the > first expression. My guess is that if you were to swap the two expressions > around, you'd find that the

Re: Why does the first expression take much longer

2014-07-12 Thread James Reeves
The JVM optimises sections of code that are frequently executed, so the second expression benefits from the optimisation that happens during the first expression. My guess is that if you were to swap the two expressions around, you'd find that the first expression always takes longer, no matter whi

Why does the first expression take much longer

2014-07-12 Thread Cecil Westerhof
I do the following (with range-length 1e8): (time (let [[t d] (split-with #(< % 12) (range range-length))] [(count d) (count t)])) (time (let [[t d] (split-with #(< % 12) (range range-length))] (into [] (reverse [(count t) (count d)] ​This gives: "Ela