Slice: Add GroupBy func (#10)

Group by: split slice into two groups, applies on each slice element a
predicate func to categorize this element.

Changes

* Add groub by func
* Add test case for this func
This commit is contained in:
donutloop authored and GitHub committed 2022-01-02 21:24:56 +08:00
1 parent 94b1a1d383
commit b4a49fccfd
4 files changed
+52

No files matched your search

+1
View File
@@ -412,6 +412,7 @@ func Unique(slice interface{}) interface{} //remove duplicate elements in slice
func Union(slices ...interface{}) interface{} //Union creates a slice of unique values, in order, from all given slices. using == for equality comparisons.
func UpdateByIndex(slice interface{}, index int, value interface{}) (interface{}, error) //update the slice element at index.
func Without(slice interface{}, values ...interface{}) interface{} //creates a slice excluding all given values
func GroupBy(slice, function interface{}) (interface{}, interface{}) // groups slice into two categories
```
#### 10. strutil is for processing string