mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-11-09 17:24:41 +00:00
Patch the Min and Max values of the expression language
This commit is contained in:
1 parent
9965370d85
commit
add9d89ccc
3 files changed
+33
-1
No files matched your search
@@ -78,6 +78,12 @@ func MinMap[K comparable, T constraints.Ordered](values map[K]T) (K, T, error) {
|
||||
// Returns an error if the container is empty or the type is unsupported.
|
||||
func Min(data interface{}) (interface{}, error) {
|
||||
v := reflect.ValueOf(data)
|
||||
method := v.MethodByName("Min")
|
||||
if method.IsValid() {
|
||||
result := method.Call(nil)[0].Interface()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
if v.Len() == 0 {
|
||||
@@ -103,6 +109,13 @@ func Min(data interface{}) (interface{}, error) {
|
||||
// Returns an error if the container is empty or the type is unsupported.
|
||||
func Max(data interface{}) (interface{}, error) {
|
||||
v := reflect.ValueOf(data)
|
||||
|
||||
method := v.MethodByName("Max")
|
||||
if method.IsValid() {
|
||||
result := method.Call(nil)[0].Interface()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
if v.Len() == 0 {
|
||||
|
||||
Reference in new issue
Block a user