Is there a neat way to partition a list into sublists of fixed length $n$, discarding a fixed number $k$ elements between each one?
E.g for $n=3, k=1$,
f[Range[1,11],3,1]={{1,2},{4,5},{7,8},{10,11}}
I can do it with
Take[#, 2] & /@ Partition[pts, 3]
(or wrapped into a function) but I was expecting Partition
to be able to do it in one call.
My use-case has a list of length <10,000, splitting into chunks of 100 with a small offset of 5 or so, so speed is not really an issue for me, but it is always interesting to see how to do these things quickly.
Partition[Range[1, 11], 2, 3]
. From the docs (Generalizations and extensions): Skip elements by using an offset larger than the block size $\endgroup$ – user1066 Oct 18 '18 at 9:47