Files
lo/docs/data/it-repeatby.md
T
Nathan Baulch e7386d9246 lint: fix inconsistent callback function parameter names (#730)
* 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>
2025-11-06 18:05:11 +01:00

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
func RepeatBy[T any](count int, callback func(index int) T) iter.Seq[T]
it#sequence#repeatby
core#slice#repeat
core#slice#times
it#sequence#times
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]