ListLazy returns the converter function for a list, but does not eval the input. Helpful for combining the Map and the List functions.
(convert func(F) T)
| 14 | // ListLazy returns the converter function for a list, but does not eval |
| 15 | // the input. Helpful for combining the Map and the List functions. |
| 16 | func ListLazy[F any, T any](convert func(F) T) func(list []F) []T { |
| 17 | return func(list []F) []T { |
| 18 | into := make([]T, 0, len(list)) |
| 19 | for _, item := range list { |
| 20 | into = append(into, convert(item)) |
| 21 | } |
| 22 | return into |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // ToStrings works for any type where the base type is a string. |
| 27 | func ToStrings[T ~string](a []T) []string { |