add min and max to the obitools expression language

This commit is contained in:
Eric Coissac
2025-05-13 16:03:03 +02:00
parent f1b9ac4a13
commit f9324dd8f4
4 changed files with 210 additions and 12 deletions

View File

@ -135,6 +135,12 @@ var OBILang = gval.NewLanguage(
length := obiutils.Len(args[0])
return (float64)(length), nil
}),
gval.Function("min", func(args ...interface{}) (interface{}, error) {
return obiutils.Min(args[0])
}),
gval.Function("max", func(args ...interface{}) (interface{}, error) {
return obiutils.Max(args[0])
}),
gval.Function("contains", func(args ...interface{}) (interface{}, error) {
if obiutils.IsAMap(args[0]) {
val := reflect.ValueOf(args[0]).MapIndex(reflect.ValueOf(args[1]))