// ClampFunc generates a closure that returns its parameter
// clamped to the range [low,high].
546130
func ClampFunc(low, high float32) func(float32) float32 {
	return func(a float32) float32 {
		return Clamp(a, low, high)
	}
}
258128
func CallFunc(receiver interface{}, methodName string, args ...interface{}) interface{} {
	var ptr reflect.Value
	var value reflect.Value

	value, ok := receiver.(reflect.Value)

	if !ok {
		value = reflect.ValueOf(receiver)
	}

	funcArgs := WrapArguments(args...)

	ptr, value = getReflectPtrAndValue(value, receiver)

	method := value.MethodByName(methodName)

	if method.IsValid() {
		return UnwrapReflectValues(method.Call(funcArgs))
	}

	method = ptr.MethodByName(methodName)

	if method.IsValid() {
		return UnwrapReflectValues(method.Call(funcArgs))
	}

	panic(fmt.Sprintf("%T type objects don't have %s method.", value.Interface(), methodName))
}
327280
func (m *Mock) AfterFunc(d time.Duration, f func()) *Timer {
	t := m.Timer(d)
	go func() {
		<-t.c
		f()
	}()
	nap()
	return t
}
935494
func GtFunc(column string, fn *Func) Cmp {
	return Cmp{
		op:     gt,
		column: column,
		value:  fn,
	}
}
266601
func (b *UpdateBuilder) AddFunc(column string, fn *Func) *UpdateBuilder {
	return b.addValue(column, fn)
}
951667
func (c Color) Clamped() Color {
	return Color{clamp01(c.R), clamp01(c.G), clamp01(c.B)}
}
756599
func (c *Cron) AddFunc(spec string, cmd func()) error {
	return c.AddJob(spec, FuncJob(cmd))
}
273908
func (m *PathRecorderMux) HandleFunc(path string, handler func(http.ResponseWriter, *http.Request)) {
	m.Handle(path, http.HandlerFunc(handler))
}
25695
func (r *Router) HandleFunc(path string, h http.HandlerFunc, ms ...Method) {
	r.Route(
		path,
		func(w http.ResponseWriter, req *Request) error {
			h(w, req.Request)
			return nil
		},
		ms...,
	)
}
1295978
func AddFunc(sched Schedule, url string, fn func(*Context) error) {
	stdSched.AddFunc(sched, url, fn)
}
749868
func (r *Router) HandleFunc(path string, f func(http.ResponseWriter,
	*http.Request)) *Route {
	return r.NewRoute().Path(path).HandlerFunc(f)
}
486429
func (m *MemLogger) GetFunc(f func(*LogEntry) bool) *LogEntry {
	if m.lock != nil {
		m.lock.Lock()
		defer m.lock.Unlock()
	}
	if m.data == nil {
		return nil
	}
	for _, ent := range *m.data {
		if f(&ent) {
			clone := ent
			return &clone
		}
	}
	return nil
}
838499
func WrapFunc(handlerFunc http.HandlerFunc) Handler {
	return HandlerFunc(func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
		handlerFunc(rw, r)
		next(rw, r)
	})
}
999450
func (ra *RemoteAddr) HandlerFunc(w http.ResponseWriter, r *http.Request) {
	ra.handleActualRequest(w, r)
}
201671
func (v *evalVisitor) callFunc(name string, funcVal reflect.Value, options *Options) reflect.Value {
	params := options.Params()

	funcType := funcVal.Type()

	// @todo Is there a better way to do that ?
	strType := reflect.TypeOf("")
	boolType := reflect.TypeOf(true)

	// check parameters number
	addOptions := false
	numIn := funcType.NumIn()

	if numIn == len(params)+1 {
		lastArgType := funcType.In(numIn - 1)
		if reflect.TypeOf(options).AssignableTo(lastArgType) {
			addOptions = true
		}
	}

	if !addOptions && (len(params) != numIn) {
		v.errorf("Helper '%s' called with wrong number of arguments, needed %d but got %d", name, numIn, len(params))
	}

	// check and collect arguments
	args := make([]reflect.Value, numIn)
	for i, param := range params {
		arg := reflect.ValueOf(param)
		argType := funcType.In(i)

		if !arg.IsValid() {
			if canBeNil(argType) {
				arg = reflect.Zero(argType)
			} else if argType.Kind() == reflect.String {
				arg = reflect.ValueOf("")
			} else {
				// @todo Maybe we can panic on that
				return reflect.Zero(strType)
			}
		}

		if !arg.Type().AssignableTo(argType) {
			if strType.AssignableTo(argType) {
				// convert parameter to string
				arg = reflect.ValueOf(strValue(arg))
			} else if boolType.AssignableTo(argType) {
				// convert parameter to bool
				val, _ := isTrueValue(arg)
				arg = reflect.ValueOf(val)
			} else {
				v.errorf("Helper %s called with argument %d with type %s but it should be %s", name, i, arg.Type(), argType)
			}
		}

		args[i] = arg
	}

	if addOptions {
		args[numIn-1] = reflect.ValueOf(options)
	}

	result := funcVal.Call(args)

	return result[0]
}
500441
func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) float64 {
	var (
		min float64 = math.MaxInt64
		max float64
	)

	for _, edge := range edges {
		// In order to obtain saner values, we reduce the capacity of a
		// channel to its base 2 logarithm.
		z := math.Log2(float64(edge.Capacity))

		if z < min {
			min = z
		}
		if z > max {
			max = z
		}
	}

	return func(x int64) float64 {
		y := math.Log2(float64(x))

		// TODO(roasbeef): results in min being zero
		return (y - min) / (max - min) * scaleFactor
	}
}
177376
func Clamp(f, low, high float32) float32 {
	return engomath.Clamp(f, low, high)
}