Initial commit of modash

This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
Leon Mika 2025-01-27 13:19:52 +11:00
commit a20530ddfd
20 changed files with 425 additions and 0 deletions

19
moslice/flatten.go Normal file
View 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
}