about summary refs log tree commit diff stats
path: root/gomponents_non_generic.go
blob: 56570d0e32ef3df7495115c142d85a3f961208e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
//go:build !go1.18
// +build !go1.18

package gomponents

// Map something enumerable to a list of Nodes.
func Map(length int, cb func(i int) Node) []Node {
	var nodes []Node
	for i := 0; i < length; i++ {
		nodes = append(nodes, cb(i))
	}
	return nodes
}