From a68bc34b0c60143bc649415fd7ff7acca70d6bdf Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 9 Nov 2021 00:10:09 +0800 Subject: ref #65: new formula functions PERCENTRANK.EXC, PERCENTRANK.INC and PERCENTRANK --- lib.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib.go') diff --git a/lib.go b/lib.go index c8e957c..f592fbe 100644 --- a/lib.go +++ b/lib.go @@ -381,6 +381,17 @@ func inStrSlice(a []string, x string) int { return -1 } +// inFloat64Slice provides a method to check if an element is present in an +// float64 array, and return the index of its location, otherwise return -1. +func inFloat64Slice(a []float64, x float64) int { + for idx, n := range a { + if x == n { + return idx + } + } + return -1 +} + // boolPtr returns a pointer to a bool with the given value. func boolPtr(b bool) *bool { return &b } -- cgit v1.2.1