mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
adds the contains function to the language
Former-commit-id: 5fb3629b56aa0180c388333e4bfbbd199edf4cf2
This commit is contained in:
@ -3,6 +3,7 @@ package obiseq
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
@ -139,6 +140,13 @@ var OBILang = gval.NewLanguage(
|
||||
length := obiutils.Len(args[0])
|
||||
return (float64)(length), nil
|
||||
}),
|
||||
gval.Function("contains", func(args ...interface{}) (interface{}, error) {
|
||||
if obiutils.IsAMap(args[0]) {
|
||||
val := reflect.ValueOf(args[0]).MapIndex(reflect.ValueOf(args[1]))
|
||||
return val.IsValid(), nil
|
||||
}
|
||||
return false, nil
|
||||
}),
|
||||
gval.Function("ismap", func(args ...interface{}) (interface{}, error) {
|
||||
ismap := obiutils.IsAMap(args[0])
|
||||
return ismap, nil
|
||||
|
Reference in New Issue
Block a user