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>
519 B
519 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Take | take | it/seq.go#L682 | it | sequence |
|
|
|
110 |
Takes the first n elements from a sequence.
seq := func(yield func(int) bool) {
yield(1)
yield(2)
yield(3)
yield(4)
}
result := it.Take(seq, 2)
var out []int
for v := range result {
out = append(out, v)
}
// out contains [1, 2]