qbtrade/pkg/fixedpoint/filter.go

21 lines
339 B
Go
Raw Permalink Normal View History

2024-06-27 14:42:38 +00:00
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
}