func detect(data1, data2 []float64) []float64 { n1, n2 := len(data1), len(data2) edges := make([]float64, 1+n1+n2+1) edges[0] = math.Inf(-1) copy(edges[1:], data1) copy(edges[1+n1:], data2) edges[1+n1+n2] = -edges[0] return sort.Unique(edges) }
// Edges returns sorted unique elements of a number of data sets, ensuring that // the first and last elements are -∞ and +∞, respectively. func Edges(data ...[]float64) []float64 { count := len(data) total := 0 for i := 0; i < count; i++ { total += len(data[i]) } edges := make([]float64, 1+total+1) edges[0] = -infinity for i, j := 0, 1; i < count; i++ { copy(edges[j:], data[i]) j += len(data[i]) } edges[1+total] = infinity return sort.Unique(edges) }