qbtrade/pkg/fixedpoint/filter.go
2024-06-27 22:42:38 +08:00

21 lines
339 B
Go

package fixedpoint
type Tester func(value Value) bool
func PositiveTester(value Value) bool {
return value.Sign() > 0
}
func NegativeTester(value Value) bool {
return value.Sign() < 0
}
func Filter(values []Value, f Tester) (slice []Value) {
for _, v := range values {
if f(v) {
slice = append(slice, v)
}
}
return slice
}