Fork me on GitHub

I'm looking for a way to do something almost like partition-by. I have a very long string, and a long vector of {:start start1 :end end1} denoting substrings in the string. The vector is already sorted by position, and the substrings are guaranteed not to overlap. I need to collect a sequence of all these substrings, and another sequence of the intervening substrings. (That is, (f "0123456789" [{:start 0 :end 2} {:start 5 :end 8}]) ==> {:in ["01" "567"] :out ["" "234" "89"]}). The string is long enough that I may need to care about efficiency.


(map (fn [{:keys [start end]}] (subs big-string start end)) positions) ?


and build a function that builds the complements of the position specifiers


or reduce over the big string taking up to the next indicator. just mash all of the start finishes into a list and reduce over those markers.


@dpsutton Thanks. Guess I'll try that and see if it is fast enough. I was afraid that the repeated subs over the entire big string would be quadratically painful. But, I should probably avoid premature optimization for now.


painful is a measurement


and if it is, just traverse once with the reduction, taking up to the next marker and alternating which collection it goes into


reduce tracking both the collection of substrings and the last end index is likely the best mix of simple / performant. subs is cheap, much cheaper than treating the string as a seq


I have a cljc file in lein project and I have cljc test for it in the test folder Now I want to include cljc test in both clj and cljs test runners and see the results of the tests to include and run cljc test in clj test runner, I have to compile it and :aot :all doesn’t seem to work in the test folder


How do I compile the cljc file in test folder ?


usually you don’t need to aot test files, but perhaps you have a gen-class or something that does require it. I’m not sure how to cause that to happen but #leiningen would perhaps be the best place to ask