Initial commit

This commit is contained in:
Yuzuki616
2024-09-12 06:04:32 +09:00
commit 3f58fa7f0d
31 changed files with 2814 additions and 0 deletions

18
common/slices/slice.go Normal file
View File

@@ -0,0 +1,18 @@
package slices
func Range[t any](sl []t, handle func(i int, v t) (_break bool)) {
for i := range sl {
b := handle(i, sl[i])
if b {
break
}
}
}
func RangeToNew[old, new any](sl []old, handle func(i int, v old) new) []new {
ns := make([]new, len(sl))
for i := range ns {
ns[i] = handle(i, sl[i])
}
return ns
}