planck

Planck ClojureScript REPL
spinningarrow 2018-03-22T13:48:10.000189Z

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

slipset 2018-03-22T20:21:44.000099Z

Looking at https://dev.clojure.org/jira/browse/CLJS-2471,

slipset 2018-03-22T20:22:04.000393Z

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

slipset 2018-03-22T20:22:17.000083Z

So I ran to planck, to check it out:

slipset 2018-03-22T20:22:43.000025Z

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

slipset 2018-03-22T20:22:59.000420Z

Running clj I get:

slipset 2018-03-22T20:23:15.000507Z

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

mfikes 2018-03-22T20:24:13.000499Z

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

slipset 2018-03-22T20:24:35.000312Z

ah, ok.

mfikes 2018-03-22T20:24:53.000177Z

I guess the "same thing" is true in Clojure

mfikes 2018-03-22T20:25:13.000106Z

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

slipset 2018-03-22T20:25:57.000506Z

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

mfikes 2018-03-22T20:25:59.000098Z

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

slipset 2018-03-22T20:26:19.000574Z

most certainly does 🙂

slipset 2018-03-22T20:26:24.000302Z

Thanks

mfikes 2018-03-22T20:27:00.000197Z

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 🙂

slipset 2018-03-22T20:27:31.000523Z

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

mfikes 2018-03-22T20:28:03.000026Z

Oh, wow. Interesting.

mfikes 2018-03-22T20:28:42.000379Z

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

mfikes 2018-03-22T20:29:23.000109Z

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

mfikes 2018-03-22T20:31:49.000156Z

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

slipset 2018-03-22T20:33:46.000657Z

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

mfikes 2018-03-22T20:34:08.000641Z

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

slipset 2018-03-22T20:51:52.000145Z

Well, at least Clojurescript knows the size of infinity 🙂

slipset 2018-03-22T20:51:55.000273Z

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

slipset 2018-03-22T20:52:06.000558Z

Clojure does not.

mfikes 2018-03-22T20:52:06.000603Z

Yes, it does 🙂

slipset 2018-03-22T20:52:29.000695Z

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

mfikes 2018-03-22T20:52:47.000524Z

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

mfikes 2018-03-22T20:53:02.000617Z

But that would be a double, I guess

mfikes 2018-03-22T20:53:14.000403Z

Or whatever, since JavaScript doesn't care

slipset 2018-03-22T20:56:59.000485Z

#yolo