mirror of
https://github.com/aykhans/dodo.git
synced 2025-09-04 02:13:33 +00:00
🎉first commit
This commit is contained in:
18
utils/slice.go
Normal file
18
utils/slice.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package utils
|
||||
|
||||
func Flatten[T any](nested [][]T) []T {
|
||||
flattened := make([]T, 0)
|
||||
for _, n := range nested {
|
||||
flattened = append(flattened, n...)
|
||||
}
|
||||
return flattened
|
||||
}
|
||||
|
||||
func Contains[T comparable](slice []T, item T) bool {
|
||||
for _, i := range slice {
|
||||
if i == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user