MCPcopy
hub / github.com/expr-lang/expr / flatten

Function flatten

builtin/lib.go:526–544  ·  view source on GitHub ↗
(arg reflect.Value, depth int)

Source from the content-addressed store, hash-verified

524}
525
526func flatten(arg reflect.Value, depth int) ([]any, error) {
527 if depth > MaxDepth {
528 return nil, ErrorMaxDepth
529 }
530 ret := []any{}
531 for i := 0; i < arg.Len(); i++ {
532 v := deref.Value(arg.Index(i))
533 if v.Kind() == reflect.Array || v.Kind() == reflect.Slice {
534 x, err := flatten(v, depth+1)
535 if err != nil {
536 return nil, err
537 }
538 ret = append(ret, x...)
539 } else {
540 ret = append(ret, v.Interface())
541 }
542 }
543 return ret, nil
544}
545
546func get(params ...any) (out any, err error) {
547 if len(params) < 2 {

Callers 1

builtin.goFile · 0.85

Calls 2

ValueFunction · 0.92
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…