I have a list that I want to split in the same way as the (partition sz step col) Clojure method or IterableLike.sliding(size: Int, step: Int) the Scala function. In particular, given the list, for example:
(1, 2, 3)
I want to be able to iterate over lists such as:
(1, 2), (2, 3)
In Clojure, this will be done with
(partition 2 1 (1, 2, 3))
and Scala it will be:
val it = Vector(1, 2, 3).sliding(2)
However, I do not have such luxury, and I hope that I will not have to give up my own. Guava has a separation method that approaches but does not offer overlap. Googling was also barren. Is there such a method, or will I have to roll on my own?
John s
source share