Skip to content

Commit

Permalink
fix arrays.window
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Dec 29, 2024
1 parent 8743509 commit 0b24575
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vlib/arrays/arrays.v
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ pub:
// Example: arrays.window([1, 2, 3, 4], size: 2) // => [[1, 2], [2, 3], [3, 4]]
// Example: arrays.window([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], size: 3, step: 2) // => [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]]
pub fn window[T](array []T, attr WindowAttribute) [][]T {
if array.len == 0 {
return [][]T{}
}
// allocate snapshot array
mut windows := [][]T{cap: array.len - attr.size + 1}

Expand Down

0 comments on commit 0b24575

Please sign in to comment.