package badtudexo import ( st "saggytrousers" ) type MissingValue[T any] struct { Value T Index int } func MissingValueNew[T any](value T, index int) MissingValue[T] { return MissingValue[T]{ value, index } } // Iterates through `check`, and returns all that are _not_ present in `src`, returning both the index in the array, and the value itself. func Missing[T comparable](check, src []T) []MissingValue[T] { var missing []MissingValue[T] for i, v := range check { if !st.InSlice(src, v) { mv := MissingValueNew(v, i) missing = append(missing, mv) } } return missing } // Iterates through `src`, and returns whether all are present in `check`. func Present[T comparable](check, src []T) bool { for _, v := range src { if !st.InSlice(check, v) { return false } } return true }