Implementing Map, Reduce, and Filter with Go Generics(bitfieldconsulting.com)
bitfieldconsulting.com
Implementing Map, Reduce, and Filter with Go Generics
https://bitfieldconsulting.com/golang/functional
https://bitfieldconsulting.com/golang/functional
For example, we couldn’t write a function that takes a slice of arbitrary type and determines whether the slice contains a given element. Instead, we had to write a function that takes some specific type, such as []int, or []string.
But this is dull, because the logic is exactly the same, whatever the type of the slice element. And now we can write that function just once, for all types. Let’s try."