Fork me on GitHub
Drew Verlee03:09:08

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


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.


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


* 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 :))

Drew Verlee12:09:31

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

Drew Verlee12:09:59

If it's bigger then that then you use onyx

Drew Verlee12:09:52

On the backend/clojure of course.


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


(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.)