Change floats min/max functions

24 views
Skip to first unread message

Brendan Tracey

unread,
Jan 10, 2015, 1:56:09 PM1/10/15
to gonu...@googlegroups.com
I was hoping to gather opinions on changing the behavior of floats.Min/floats.Max. The proposed new behavior is to have

func floats.MinIdx(s []float64) int
func floats.Min(s []float64) float64
func floats.MaxIdx(s []float64) int
func floats.Max(s []float64) float64

The current signature was chosen to keep the number of functions small, and both of these operations are useful. However, I have found the current behavior annoying. Frequently these operations are building blocks to larger expressions, and it's nice to be able to express them as such. This proposal does increase the API surface, but it seems to me that's it's worth it to make floats more smooth to use. This is a breaking change, but
a) now's a good time to do it with the current breaking changes
b) most code uses one or the other, fix is an easy deletion
c) At least as per godoc, most of the code that imports floats is either in the gonum suite, or is in packages owned by me, so it's a good time to change before there is too much code that depends on the behavior

Comments?

Leo Neumeyer

unread,
Jan 10, 2015, 3:20:36 PM1/10/15
to gonu...@googlegroups.com
an alternative, if the most common use case is to get both values:

func floats.MinIdx(s []float64) (max float64, ind int)
func floats.Min(s []float64) float64
func floats.MaxIdx(s []float64) 
(max float64, ind int)
func floats.Max(s []float64) float64


in any case, let us know when you push the change.

Brendan Tracey

unread,
Jan 10, 2015, 4:10:02 PM1/10/15
to Leo Neumeyer, gonu...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "gonum-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gonum-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages