|
|
|
@ -54,16 +54,6 @@ func assert(cond bool) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func deleteFromSlice[T comparable](slc []T, val T) []T {
|
|
|
|
|
toReturn := make([]T, 0, len(slc))
|
|
|
|
|
for _, v := range slc {
|
|
|
|
|
if v != val {
|
|
|
|
|
toReturn = append(toReturn, v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return toReturn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure that the given elements are only appended to the given slice if they
|
|
|
|
|
// don't already exist. Returns the new slice, and the number of unique items appended.
|
|
|
|
|
func unique_append[T comparable](slc []T, items ...T) ([]T, int) {
|
|
|
|
@ -149,13 +139,6 @@ func allCases(r rune) []rune {
|
|
|
|
|
return []rune{unicode.ToLower(r), unicode.ToUpper(r), unicode.ToTitle(r)}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expands a slice to the given length
|
|
|
|
|
func expandSlice[T any](slc []T, newSize int) []T {
|
|
|
|
|
toRet := make([]T, newSize)
|
|
|
|
|
copy(toRet, slc)
|
|
|
|
|
return toRet
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func isHex(c rune) bool {
|
|
|
|
|
return slices.Contains([]rune("0123456789abcdefABCDEF"), c)
|
|
|
|
|
}
|
|
|
|
|