Fork me on GitHub
#planck
<
2018-03-22
>
spinningarrow13:03:10

Got it; thanks for the tips @mfikes! (and for planck of course!)

slipset20:03:04

I tried to figure out what a chunked-seq is.

slipset20:03:17

So I ran to planck, to check it out:

slipset20:03:43

cljs.user=> (chunked-seq? (seq (range 1000)))
false

slipset20:03:59

Running clj I get:

slipset20:03:15

user=> (chunked-seq? (seq (range 100)))
true

mfikes20:03:13

Well, in ClojureScript, range is special. And calling seq on it returns the same thing back.

mfikes20:03:53

I guess the "same thing" is true in Clojure

mfikes20:03:13

But, the point is that (range) returns a Range

slipset20:03:57

Yeah, I saw that when typing (type (range))

mfikes20:03:59

Maybe (chunked-seq? (seq (vec (range 1000)))) helps dig into what it is?

slipset20:03:19

most certainly does 🙂

mfikes20:03:00

No prob. I've not myself dug deeply into chunked seq stuff. It is this substrate that has always been there and worked properly, from my perspective 🙂

slipset20:03:31

It seems that in Clojure (range) is not a chunked seq, but any call to range which yields a finite range is?

mfikes20:03:03

Oh, wow. Interesting.

mfikes20:03:42

Hah, (range) and (range 1000) are of different types.

mfikes20:03:23

Since iterate is directly reducible, (range) would be faster as a result

mfikes20:03:49

So @slipset The stuff I was saying about Clojure's range was evidently true before https://github.com/clojure/clojure/commit/07d6129a9847f62010079ab6f04b7930c2a593e4

slipset20:03:46

That's way more information than I can handle at this hour 🙂

mfikes20:03:08

So... a consequence is that ClojureScript's range could be updated to be chunked... hah. And then mapping over ranges would be faster.

slipset20:03:52

Well, at least Clojurescript knows the size of infinity 🙂

slipset20:03:55

21:50 $ ./script/repljs
ClojureScript 1.10.168
cljs.user=> (count (range))
1.7976931348623157e+308
cljs.user=>

slipset20:03:06

Clojure does not.

mfikes20:03:06

Yes, it does 🙂

slipset20:03:29

or, it might be 42, it just takes some time for Clojure to calculate that.

mfikes20:03:47

A silly part of me wonders if that ClojureScript call should return ##Inf

mfikes20:03:02

But that would be a double, I guess

mfikes20:03:14

Or whatever, since JavaScript doesn't care