package strain // Ints is a slice of int type Ints []int // Lists is a slice of int slices type Lists [][]int // Strings is a slice of strings type Strings []string // Keep runs the Ints through a function and returns the ones that succeed func (i Ints) Keep(kf func(int) bool) Ints { var ret Ints for idx := range i { if kf(i[idx]) { ret = append(ret, i[idx]) } } return ret } // Discard runs the Ints through a function and returns the ones that fail func (i Ints) Discard(df func(int) bool) Ints { var ret Ints for idx := range i { if !df(i[idx]) { ret = append(ret, i[idx]) } } return ret } // Keep runs the Lists through a function and returns the ones that succeed func (l Lists) Keep(kf func([]int) bool) Lists { var ret Lists for idx := range l { if kf(l[idx]) { ret = append(ret, l[idx]) } } return ret } // Keep runs the Strings through a function and returns the ones that succeed func (s Strings) Keep(kf func(string) bool) Strings { var ret Strings for idx := range s { if kf(s[idx]) { ret = append(ret, s[idx]) } } return ret }