I listened to the partition-by
& group-by
episode and one thing you mentioned is using partition-by
for "splitting" a sequence into two portions.
Wouldn't split-with
be a more suitable for that purpose? https://stackoverflow.com/questions/64208708/replicate-java-peek-stream-method-in-clojure
Yes, if you know that you will only get two portions, then split-with would work as well
Looks like it depends on which data structure you're using, and laziness. Stackoverflow question was specifically about a side effect, so I think maybe they could use a queue instead of a list. I'm curious as well about the difference.
I also think it's interesting that split-with
returns a vector (eager) of two lazy sequences, so they are computed as you consume them