Minor refactor to run additional targets recursively

This commit is contained in:
David Allen 2024-06-27 11:19:16 -06:00
parent 2154657d34
commit cccbb1ad25
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
2 changed files with 81 additions and 52 deletions

View file

@ -61,3 +61,21 @@ func GitCommit() string {
return strings.TrimRight(string(stdout), "\n")
}
// NOTE: would it be better to use slices.DeleteFunc instead
func RemoveIndex[T comparable](s []T, index int) []T {
ret := make([]T, 0)
ret = append(ret, s[:index]...)
return append(ret, s[index+1:]...)
}
func CopyIf[T comparable](s []T, condition func(t T) bool) []T {
var f = make([]T, 0)
for _, e := range s {
if condition(e) {
f = append(f, e)
}
}
return f
}