or .slide with its arguments windowLength and stepSize? a= [1, 2, 3, 4, 5, 6, 7, 8, 9] a.slide(3, 1).clump(3) a.slide(3, 2).clump(3) _f0 Am 24.10.2007 um 14:06 schrieb James Harkins:
I would consider this: a = (1..9); ((0..6) +.t (0..2)).collect(a[_]); ((0, 2 .. 6) +.t (0..2)).collect(a[_]);See the Adverbs helpfile. Also I use the property of Array:at that if you pass in an array of indices, you get an array with the values at each corresponding index of the source array, e.g., a[[0, 5]] == [1, 6]hjh On Oct 24, 2007, at 7:45 AM, Stefan Kersten wrote:i'm looking for the nicest way to separate an array into overlapping subarrays, e.g. like this:[1, 2, 3, 4, 5, 6, 7, 8, 9]-> [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]-> [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]] any suggestions? thx, <sk>
#|
fredrikolofsson.com klippav.org musicalfieldsforever.com
|#