clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-09-06T03:00:08.268Z

Err. @misha ((frequencies "\n\n") "\n") => 2 But I didn't expect the behavior of split lines. I would have expected a blank string for each new line

misha 2020-09-06T09:52:05.269900Z

yeah, frequencies seems to be 10x faster than count re-seq, but regex is actually #"\n\r|\r\n|\n|\r" or something like this.

misha 2020-09-06T09:56:03.271500Z

all those shenanigans are exactly because empty strings are omitted from "default" tools you'd reach for :(

misha 2020-09-06T10:01:36.273500Z

* 10x faster on that little useless string that is. on an actual text (any source code file) - it is ∞ slower (imagine frequencies clojure.core.clj just to count lines :))

2020-09-06T12:02:31.276500Z

If the source is big enough use the reducer library/ns.

2020-09-06T12:02:59.277100Z

If it's bigger then that then you use onyx

2020-09-06T12:03:52.278100Z

On the backend/clojure of course.

misha 2020-09-06T12:37:58.282800Z

~20k lines, worst case scenario – need to run it within 16msec to maintain 60fps :opieop: on client, hence writing in #clojurescript channel

misha 2020-09-06T12:40:41.284600Z

(ofc. for such use case, there will be more involved datastructures and supporting state, so lines count will be custom fn, etc. the point of the PSA - str/split-lines ignores empty lines.)

2020-09-06T13:17:22.284800Z

@thedanpetrov So did you find the culprit?

athomasoriginal 2020-09-06T19:31:31.285200Z

If this hasn’t been resolved, there is a video illustrating using axios: https://www.youtube.com/watch?v=0zaw3gcf0Sk

1👍