mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
89b0e25e2c
We also move the `fn/stream.go` into the package `lnutils`. Eventually we will put all the [utility functions](https://github.com/lightninglabs/taro/tree/main/chanutils) into this package.
14 lines
245 B
Go
14 lines
245 B
Go
package lnutils
|
|
|
|
// Map takes an input slice, and applies the function f to each element,
|
|
// yielding a new slice.
|
|
func Map[T1, T2 any](s []T1, f func(T1) T2) []T2 {
|
|
r := make([]T2, len(s))
|
|
|
|
for i, v := range s {
|
|
r[i] = f(v)
|
|
}
|
|
|
|
return r
|
|
}
|