From 1e5e0aa0ecbade7c748cf920b405635e45b1796c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 26 Jun 2022 17:44:10 -0600 Subject: wip better vol --- pkg/util/generic.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pkg/util') diff --git a/pkg/util/generic.go b/pkg/util/generic.go index 79096ab..7ff2445 100644 --- a/pkg/util/generic.go +++ b/pkg/util/generic.go @@ -13,6 +13,17 @@ func InSlice[T comparable](needle T, haystack []T) bool { return false } +func RemoveFromSlice[T comparable](haystack []T, needle T) []T { + for i, straw := range haystack { + if needle == straw { + return append( + haystack[:i], + RemoveFromSlice(haystack[i+1], item)...) + } + } + return haystack +} + func Max[T constraints.Ordered](a, b T) T { if a > b { return a -- cgit v1.2.3-2-g168b