Files
lo/docs/data/it-times.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

818 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
Times times it/seq.go#L202 it sequence
func Times[T any](count int, callback func(index int) T) iter.Seq[T]
https://go.dev/play/p/0W4IRzQuCEc
it#sequence#times
core#slice#times
it#math#range
70

Invokes a callback function n times and returns a sequence of the results.

Examples:

seq := it.Times(5, func(index int) int {
    return index * 2
})
var result []int
for v := range seq {
    result = append(result, v)
}
// result contains 0, 2, 4, 6, 8
seq := it.Times(3, func(index int) string {
    return fmt.Sprintf("item-%d", index+1)
})
var result []string
for v := range seq {
    result = append(result, v)
}
// result contains "item-1", "item-2", "item-3"