Move 'genRange' function to 'cmd'

This commit is contained in:
2025-01-30 09:03:07 -05:00
parent ee6bb3959c
commit c3c3829ac9
2 changed files with 17 additions and 11 deletions

View File

@@ -2,6 +2,10 @@ package main
import "slices"
type character interface {
int | rune
}
// Returns all elements in slice A that are NOT in slice B
func setDifference[T comparable](s1 []T, s2 []T) []T {
toReturn := make([]T, 0, len(s1))
@@ -12,3 +16,12 @@ func setDifference[T comparable](s1 []T, s2 []T) []T {
}
return toReturn
}
// Generate numbers in a range - start (inclusive) to end (exclusive)
func genRange[T character](start, end T) []T {
toRet := make([]T, end-start)
for i := start; i < end; i++ {
toRet[i-start] = i
}
return toRet
}