/ / Internal helper functions--different kinds of comparisions. /
507495
function _same_array(one, two){
	var retval = true;
	if( one.length != two.length ){
	    retval = false;
	}else{
	    for( var i = 0; i < one.length; i++ ){
		if( one[i] != two[i] ){
		    retval = false;
		    break;
		}
	    }
	}
	return retval;
    }
260645
func interpolationFuncMatchKeys() ast.Function {
	return ast.Function{
		ArgTypes:   []ast.Type{ast.TypeList, ast.TypeList, ast.TypeList},
		ReturnType: ast.TypeList,
		Callback: func(args []interface{}) (interface{}, error) {
			output := make([]ast.Variable, 0)

			values, _ := args[0].([]ast.Variable)
			keys, _ := args[1].([]ast.Variable)
			searchset, _ := args[2].([]ast.Variable)

			if len(keys) != len(values) {
				return nil, fmt.Errorf("length of keys and values should be equal")
			}

			for i, key := range keys {
				for _, search := range searchset {
					if res, err := compareSimpleVariables(key, search); err != nil {
						return nil, err
					} else if res == true {
						output = append(output, values[i])
						break
					}
				}
			}
			// if searchset is empty, then output is an empty list as well.
			// if we haven't matched any key, then output is an empty list.
			return output, nil
		},
	}
}
1307000
func Function(fn string) {
	if e, ok := encodingDefinition(); ok {
		e.Function = fn
	}
}
677325
func (a VarRefs) Less(i, j int) bool {
	if a[i].Val != a[j].Val {
		return a[i].Val < a[j].Val
	}
	return a[i].Type < a[j].Type
}
401930
func CompareComparableNumeric(x1 interface{}, x2 interface{}) int {
	// x1 should be numeric
	switch x1 := x1.(type) {
	case bool:
		b1 := bool(x1)
		if b1 {
			return compareNumericInt(int64(1), x2)
		}
		return compareNumericInt(int64(0), x2)
	case int, int8, int32, int64:
		n1 := reflect.ValueOf(x1).Int()
		return compareNumericInt(n1, x2)
	case uint, uint8, uint32, uint64:
		n1 := reflect.ValueOf(x1).Uint()
		return compareNumericUint(n1, x2)
	case float32, float64:
		n1 := reflect.ValueOf(x1).Float()
		return compareNumericFloat(n1, x2)
	}
	panic("Expect first arg to be numeric")
}
439890
func (rf *RulerRule) compare(comp int, value interface{}) *RulerRule {
	var comparator string
	switch comp {
	case eq:
		comparator = "eq"
	case neq:
		comparator = "neq"
	case lt:
		comparator = "lt"
	case lte:
		comparator = "lte"
	case gt:
		comparator = "gt"
	case gte:
		comparator = "gte"
	case contains:
		comparator = "contains"
	case matches:
		comparator = "matches"
	case ncontains:
		comparator = "ncontains"
	}

	// if this thing has a comparator already, we need to make a new ruler filter
	if rf.Comparator != "" {
		rf = &RulerRule{
			rf.Ruler,
			&Rule{
				comparator,
				rf.Path,
				value,
			},
		}
		// attach the new filter to the ruler
		rf.Ruler.rules = append(rf.Ruler.rules, rf.Rule)
	} else {
		//if there is no comparator, we can just set things on the current filter
		rf.Comparator = comparator
		rf.Value = value
	}

	return rf
}
665918
func interpolationFuncValues(vs map[string]ast.Variable) ast.Function {
	return ast.Function{
		ArgTypes:   []ast.Type{ast.TypeMap},
		ReturnType: ast.TypeList,
		Callback: func(args []interface{}) (interface{}, error) {
			mapVar := args[0].(map[string]ast.Variable)
			keys := make([]string, 0)

			for k, _ := range mapVar {
				keys = append(keys, k)
			}

			sort.Strings(keys)

			values := make([]string, len(keys))
			for index, key := range keys {
				if value, ok := mapVar[key].Value.(string); ok {
					values[index] = value
				} else {
					return "", fmt.Errorf("values(): %q has element with bad type %s",
						key, mapVar[key].Type)
				}
			}

			variable, err := hil.InterfaceToVariable(values)
			if err != nil {
				return nil, err
			}

			return variable.Value, nil
		},
	}
}
287142
func (u Uint32) If(fn func(uint32)) {
	if u.Present() {
		fn(*u.value)
	}
}
866870
func FloatEqualFunc(epsilon float32) func(float32, float32) bool {
	return func(a, b float32) bool {
		return FloatEqualThreshold(a, b, epsilon)
	}
}
50921
func interpolationFuncSlice() ast.Function {
	return ast.Function{
		ArgTypes: []ast.Type{
			ast.TypeList, // inputList
			ast.TypeInt,  // from
			ast.TypeInt,  // to
		},
		ReturnType: ast.TypeList,
		Variadic:   false,
		Callback: func(args []interface{}) (interface{}, error) {
			inputList := args[0].([]ast.Variable)
			from := args[1].(int)
			to := args[2].(int)

			if from < 0 {
				return nil, fmt.Errorf("from index must be >= 0")
			}
			if to > len(inputList) {
				return nil, fmt.Errorf("to index must be <= length of the input list")
			}
			if from > to {
				return nil, fmt.Errorf("from index must be <= to index")
			}

			var outputList []ast.Variable
			for i, val := range inputList {
				if i >= from && i < to {
					outputList = append(outputList, val)
				}
			}
			return outputList, nil
		},
	}
}
785893
func InsideBoundingBoxEqual(o1, o2 *InsideBoundingBoxOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
853898
func deriveCompare(this, that []*MyStruct) int {
	if this == nil {
		if that == nil {
			return 0
		}
		return -1
	}
	if that == nil {
		return 1
	}
	if len(this) != len(that) {
		if len(this) < len(that) {
			return -1
		}
		return 1
	}
	for i := 0; i < len(this); i++ {
		if c := deriveCompare_(this[i], that[i]); c != 0 {
			return c
		}
	}
	return 0
}
723446
func interpolationFuncLower() ast.Function {
	return ast.Function{
		ArgTypes:   []ast.Type{ast.TypeString},
		ReturnType: ast.TypeString,
		Callback: func(args []interface{}) (interface{}, error) {
			toLower := args[0].(string)
			return strings.ToLower(toLower), nil
		},
	}
}
499616
func SelectEqual(v string) func(string) bool {
	return func(p string) bool {
		return v == p
	}
}
469537
func functionCompleter(substring string) string {
	found := ""
	for _, fName := range profileFunctionNames {
		if strings.Contains(fName, substring) {
			if found != "" {
				return substring
			}
			found = fName
		}
	}
	if found != "" {
		return found
	}
	return substring
}
472455
func InternalError(field *Path, err error) *Error {
	return &Error{ErrorTypeInternal, field.String(), nil, err.Error()}
}
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
		},
	}
}