Four is better than 32, but still.
I found the explanation for this on stackoverflow.com. Stuart Sierra
wrote,
This is due to the definition of =, which, when given a sequence of
arguments, forces the first 4:
(defn =
;; ... other arities ...
([x y more]
(if (= x y)
(if (next
On Dec 31, 12:48 am, Ken Wesson kwess...@gmail.com wrote:
Is mapcat also semi-eager, then?
I guess so. The Clojure 1.1 release notes also say, Some of the
sequence processing functions (like map and
filter) are now chunk-aware and leverage this efficiency. I should
have mentioned that.
--
ehanneken ehanne...@pobox.com writes:
I spent a long time debugging some Clojure code yesterday. The
essence of it looked similar to this:
(defn items []
(mapcat expensive-function (range 0 4000 100)))
. . . (take 5 (items)) . . .
I tried to distill the problem down by defining a
Chas,
Thanks for your help. However, modifying the code to use mapcat
instead of (map println) seems to cause some chunking:
(defn tenify [n]
(do
(println \ n \)
[n n n n n n n n n n]))
= (- (range 50)
(mapcat list)
(mapcat tenify)
first)
0
1
2
3
0
And indeed,
I spent a long time debugging some Clojure code yesterday. The
essence of it looked similar to this:
(defn items []
(mapcat expensive-function (range 0 4000 100)))
. . . (take 5 (items)) . . .
expensive-function is a function that issues an HTTP GET to retrieve a
vector of data. Since
On Fri, Dec 31, 2010 at 12:25 AM, ehanneken ehanne...@pobox.com wrote:
I spent a long time debugging some Clojure code yesterday. The
essence of it looked similar to this:
(defn items []
(mapcat expensive-function (range 0 4000 100)))
. . . (take 5 (items)) . . .
expensive-function is a
On Fri, Dec 31, 2010 at 12:25 AM, ehanneken ehanne...@pobox.com wrote:
I spent a long time debugging some Clojure code yesterday. The
essence of it looked similar to this:
(defn items []
(mapcat expensive-function (range 0 4000 100)))
. . . (take 5 (items)) . . .
expensive-function