mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
e7386d9246
* Fix linting * Use is.ElementsMatch This will ignore the ordering of the final intersection. Especially important when checking old versions of go that do not guarantee an order when iterating through maps. * lint: fix inconsistent callback function parameter names * lint: rename "iteratee" to "transform" for *Map helpers * lint: rename "project" parameters to "transform" * lint: rename "cb" parameters to "callback" * lint: rename "iteratee" to "callback" for ForEach helpers --------- Co-authored-by: Franky W. <frankywahl@users.noreply.github.com> Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
821 B
821 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| RepeatBy | repeatby | it/seq.go#L388 | it | sequence |
|
|
|
130 |
Builds a sequence with values returned by N calls of callback.
result := it.RepeatBy(3, func(index int) string {
return fmt.Sprintf("item-%d", index+1)
})
var output []string
for item := range result {
output = append(output, item)
}
// output contains ["item-1", "item-2", "item-3"]
result2 := it.RepeatBy(5, func(index int) int {
return index * 2
})
var output2 []int
for item := range result2 {
output2 = append(output2, item)
}
// output2 contains [0, 2, 4, 6, 8]