mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-06-24 09:41:00 +00:00
feat: add min/max filtering and saturating subtraction utilities
Introduce generic and reflection-based utilities for filtering slices and maps by minimum/maximum thresholds, along with saturating subtraction. The `obiutils` package provides type-safe generic implementations alongside dynamic reflection dispatchers to handle arbitrary ordered and numeric types. These are exposed as GVAL expression functions in `obiseq`, extending the language's built-in filtering and numeric capabilities.
This commit is contained in:
@@ -141,6 +141,19 @@ var OBILang = gval.NewLanguage(
|
||||
gval.Function("max", func(args ...interface{}) (interface{}, error) {
|
||||
return obiutils.Max(args[0])
|
||||
}),
|
||||
|
||||
gval.Function("filtermin", func(args ...interface{}) (interface{}, error) {
|
||||
return obiutils.FilterMin(args[0], args[1])
|
||||
}),
|
||||
|
||||
gval.Function("filtermax", func(args ...interface{}) (interface{}, error) {
|
||||
return obiutils.FilterMax(args[0], args[1])
|
||||
}),
|
||||
|
||||
gval.Function("saturatingsub", func(args ...interface{}) (interface{}, error) {
|
||||
return obiutils.SaturatingSub(args[0], args[1])
|
||||
}),
|
||||
|
||||
gval.Function("contains", func(args ...interface{}) (interface{}, error) {
|
||||
if obiutils.IsAMap(args[0]) {
|
||||
val := reflect.ValueOf(args[0]).MapIndex(reflect.ValueOf(args[1]))
|
||||
|
||||
Reference in New Issue
Block a user