A high order function library for applying various array methods like map, reduce, filters etc, using generics.
- Foreach
- Map
- Filter
- Concat
- Fill
- GroupBy
- Reduce
- Find
- Sum
- Every
For eg. given an array for strings, filter if the string contain the word "test". With funktors, you can solve it as follows:
input := []string{"test123", "123all", "testvalue"}
values := funktors.Filter(input, func(index int, a string) bool {
return strings.Contains(a, "test")
})
log.Println(values)
}
Without funktors, it would look something like this:
input := []string{"test123", "123all", "testvalue"}
var output []string{}
for _, v := range input {
if strings.Contains(v, "test") {
output = append(output, v)
}
}
log.Println(output)