mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
c1d11cb658
* add iterator slice helpers and channel dedup/tee
* note unbounded memory growth in Distinct; simplify Take
* avoid extra iteration in Take/TakeWhile/TakeFilter and precompute Sliding step
* avoid reallocations in Sliding overlap shift
* sliding uses ring buffer
* refactor Sliding and expand TestSliding
* Remove Tee; add TakeFilter variant, rewrite Sliding
* remove channel Distinct/DistinctBy
* TakeFilter/TakeFilterI for slice
* Revert "TakeFilter/TakeFilterI for slice"
This reverts commit 6d2fcdc07b.
* doc add new helpers to llms.txt
---------
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
726 B
726 B
name, slug, sourceRef, category, subCategory, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | variantHelpers | similarHelpers | position | signatures | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Window | window | slice.go#L289 | core | slice |
|
|
145 |
|
Creates a slice of sliding windows of a given size. Each window overlaps with the previous one by size-1 elements. This is equivalent to Sliding(collection, size, 1).
lo.Window([]int{1, 2, 3, 4, 5}, 3)
// [][]int{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}
lo.Window([]float64{20, 22, 21, 23, 24}, 3)
// [][]float64{{20, 22, 21}, {22, 21, 23}, {21, 23, 24}}