// FnSplit resolves the 'Fn::Split' AWS CloudFormation intrinsic function.
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-split.html
511344
func FnSplit(name string, input interface{}, template interface{}) interface{} {

	// { "Fn::Split" : [ "delimiter", "source string" ] }

	// Check that the input is an array
	if arr, ok := input.([]interface{}); ok {
		// The first element should be a string (the delimiter)
		if delim, ok := arr[0].(string); ok {
			// The second element should be a string (the content to join)
			if str, ok := arr[1].(string); ok {
				return strings.Split(str, delim)
			}
		}
	}

	return []string{}

}
594756
func (hpt *hostParamTransformer) split(s, sep string) []string {
	slice := []string{}
	n := strings.Count(s, sep) + 1
	c := sep[0]
	start := 0

	var a []string
	if cap(slice) == n {
		a = slice
	} else {
		a = make([]string, n)
	}

	na := 0
	for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
		if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) && (i == 0 || s[i-1] != '\\') {
			a[na] = s[start:i]
			na++
			start = i + len(sep)
			i += len(sep) - 1
		}
	}
	a[na] = s[start:]
	slice = a[0 : na+1]
	return slice
}
97200
func DumpClosureEnvFunction(env *Zlisp, name string, args []Sexp) (Sexp, error) {
	if len(args) != 1 {
		return SexpNull, WrongNargs
	}

	switch f := args[0].(type) {
	case *SexpFunction:
		s := ClosureToString(f, env)
		return &SexpStr{S: s}, nil
	default:
		return SexpNull, fmt.Errorf("_closdump needs an *SexpFunction to inspect")
	}
}
845914
func interpolationFuncSplit() ast.Function {
	return ast.Function{
		ArgTypes:   []ast.Type{ast.TypeString, ast.TypeString},
		ReturnType: ast.TypeList,
		Callback: func(args []interface{}) (interface{}, error) {
			sep := args[0].(string)
			s := args[1].(string)
			elements := strings.Split(s, sep)
			return stringSliceToVariableValue(elements), nil
		},
	}
}
1101522
func ReturnFnType(fnt *FunctionType) {
	if a, ok := fnt.a.(*FunctionType); ok {
		ReturnFnType(a)
	}

	if b, ok := fnt.b.(*FunctionType); ok {
		ReturnFnType(b)
	}

	fnt.a = nil
	fnt.b = nil
	fnTypePool.Put(fnt)
}
251536
func wrapFunc(fn Func) FuncCtx {
	if fn == nil {
		return nil // be sure not to wrap a bad function.
	}
	return func(ctx context.Context, fl FieldLevel) bool {
		return fn(fl)
	}
}
60678
func lineSplit(s string, margin int) []string {
	var ret []string
	var buf bytes.Buffer
	for _, r := range s {
		if r == '\n' {
			ret = append(ret, stripWhitespace(buf.String(), margin))
			buf.Reset()
		} else {
			buf.WriteRune(r)
		}
	}
	return append(ret, stripWhitespace(buf.String(), margin))
}
990874
func Split(sep, str cty.Value) (cty.Value, error) {
	return SplitFunc.Call([]cty.Value{sep, str})
}
779280
func interpolationFuncFormat() ast.Function {
	return ast.Function{
		ArgTypes:     []ast.Type{ast.TypeString},
		Variadic:     true,
		VariadicType: ast.TypeAny,
		ReturnType:   ast.TypeString,
		Callback: func(args []interface{}) (interface{}, error) {
			format := args[0].(string)
			return fmt.Sprintf(format, args[1:]...), nil
		},
	}
}
757841
func (n *Node) splitAt(i int) (interface{}, *Node) {
	if n.IsLeaf {
		return n.splitLeafAt(i)
	}

	return n.splitInternalAt(i)
}
190834
func Expand(s string, fns ...KeyFunc) string {
	val, _ := ExpandStrict(s, append(fns, Empty)...)
	return val
}
1327487
func splitAndNormalizeTLFNameCanonicalize(g *libkb.GlobalContext, name string, public bool) (writerNames, readerNames []string, extensionSuffix string, err error) {
	writerNames, readerNames, extensionSuffix, err = SplitAndNormalizeTLFName(g, name, public)
	if retryErr, retry := err.(TlfNameNotCanonical); retry {
		return SplitAndNormalizeTLFName(g, retryErr.NameToTry, public)
	}
	return writerNames, readerNames, extensionSuffix, err
}
214733
func NewSplitSize(children ...SplitSizeChild) SplitSize {
	s := SplitSize(children)
	sort.Sort(s)
	return s
}
94061
func (d Data) GetStringsSplit(key string, delim string) []string {
	if !d.KeyExists(key) || len(d.Values[key]) == 0 {
		return nil
	}
	return strings.Split(d.Values[key][0], delim)
}
1302452
func (f *Function) versionsToCleanup() ([]*lambda.FunctionConfiguration, error) {
	versions, err := f.versions()
	if err != nil {
		return nil, err
	}

	if *f.RetainedVersions == 0 {
		return versions, nil
	}

	if len(versions) > *f.RetainedVersions {
		return versions[:len(versions)-*f.RetainedVersions], nil
	}

	return nil, nil
}
935625
func (conn *FakeVTGateConn) AddSplitQuery(
	keyspace string,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	splitColumns []string,
	splitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm,
	expectedResult []*vtgatepb.SplitQueryResponse_Part) {

	reply := make([]*vtgatepb.SplitQueryResponse_Part, len(expectedResult))
	copy(reply, expectedResult)
	key := getSplitQueryKey(keyspace, sql, splitColumns, splitCount, numRowsPerQueryPart, algorithm)
	conn.splitQueryMap[key] = &splitQueryResponse{
		splitQuery: &querySplitQuery{
			Keyspace:            keyspace,
			SQL:                 sql,
			BindVariables:       bindVariables,
			SplitColumns:        splitColumns,
			SplitCount:          splitCount,
			NumRowsPerQueryPart: numRowsPerQueryPart,
			Algorithm:           algorithm,
		},
		reply: reply,
		err:   nil,
	}
}
730398
func (c ConversionFuncs) Add(fns ...interface{}) error {
	for _, fn := range fns {
		fv := reflect.ValueOf(fn)
		ft := fv.Type()
		if err := verifyConversionFunctionSignature(ft); err != nil {
			return err
		}
		c.fns[typePair{ft.In(0).Elem(), ft.In(1).Elem()}] = fv
	}
	return nil
}