Initial commit of modash
This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
commit
a20530ddfd
20 changed files with 425 additions and 0 deletions
19
moslice/flatten.go
Normal file
19
moslice/flatten.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package moslice
|
||||
|
||||
func Flatten[T any](tss [][]T) []T {
|
||||
if len(tss) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
entireLen := 0
|
||||
for _, ts := range tss {
|
||||
entireLen += len(ts)
|
||||
}
|
||||
|
||||
newTs := make([]T, 0, entireLen)
|
||||
for _, ts := range tss {
|
||||
newTs = append(newTs, ts...)
|
||||
}
|
||||
|
||||
return newTs
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue