Files
lo/docs/data/it-sliding.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

744 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
Sliding sliding it/seq.go#L329 it sequence
func Sliding[T any](collection iter.Seq[T], size, step int) iter.Seq[[]T]
https://go.dev/play/p/mzhO4CZeiik
it#sequence#sliding
core#slice#sliding
80

Creates a sequence of sliding windows of a given size with a given step. If step equals size, windows don't overlap.

seq := func(yield func(int) bool) {
    yield(1)
    yield(2)
    yield(3)
    yield(4)
    yield(5)
    yield(6)
    yield(7)
    yield(8)
}
windows := it.Sliding(seq, 2, 3)
var result [][]int
for w := range windows {
    result = append(result, w)
}
// result contains [1 2], [4 5], [7 8]