Updated map and reduce function names so that they aren't exported
This commit is contained in:
@@ -74,7 +74,7 @@ func allEqual[T comparable](items ...T) bool {
|
||||
|
||||
// Map function - convert a slice of T to a slice of V, based on a function
|
||||
// that maps a T to a V
|
||||
func Map[T, V any](slc []T, fn func(T) V) []V {
|
||||
func funcMap[T, V any](slc []T, fn func(T) V) []V {
|
||||
toReturn := make([]V, len(slc))
|
||||
for i, val := range slc {
|
||||
toReturn[i] = fn(val)
|
||||
@@ -84,7 +84,7 @@ func Map[T, V any](slc []T, fn func(T) V) []V {
|
||||
|
||||
// Reduce function - reduces a slice of a type into a value of the type,
|
||||
// based on the given function.
|
||||
func Reduce[T any](slc []T, fn func(T, T) T) T {
|
||||
func funcReduce[T any](slc []T, fn func(T, T) T) T {
|
||||
if len(slc) == 0 {
|
||||
panic("Reduce on empty slice.")
|
||||
}
|
||||
|
Reference in New Issue
Block a user