Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-20 Thread Brent Royal-Gordon via swift-evolution
> Maybe this has been addressed before on another topic, but why are minmax(), > minIndex(), maxIndex() and minmaxIndices() functions rather than read-only > properties? The API Guidelines say this: >>> Document the complexity of any computed property that is not O(1). People >>> often assume

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-19 Thread Dave Abrahams via swift-evolution
on Tue Apr 19 2016, Karl Wagner wrote: > I understand what you’re saying about API bloat, but I still think this is a > fair proposal: > > 1. It’s not a very outlandish thing. No, of course it isn't. That doesn't mean we should add it, either. Note: I'm not

[swift-evolution] [Draft] Expanded min/max algorithms

2016-04-19 Thread Karl via swift-evolution
Maybe this has been addressed before on another topic, but why are minmax(), minIndex(), maxIndex() and minmaxIndices() functions rather than read-only properties? It seems like things would be much cleaner without the brackets, and it’s shorter to implement in some cases as you can back it

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-19 Thread Karl Wagner via swift-evolution
I understand what you’re saying about API bloat, but I still think this is a fair proposal: 1. It’s not a very outlandish thing. We already have min/max. Adding a function for the mean would probably be too much. Collection is a bit of a special API; it should be reasonably comprehensive to

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-19 Thread Dave Abrahams via swift-evolution
on Tue Apr 19 2016, "Vladimir.S" wrote: > Agree with notes about minIndex vs indexOfMin. Seems clear for me the > later should be chosen. We have .min() so it is naturally to have > .indexOfMin > > But I disagree on specialized algorithms. Can't understand, how > custom-made function with block

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-19 Thread Vladimir.S via swift-evolution
Agree with notes about minIndex vs indexOfMin. Seems clear for me the later should be chosen. We have .min() so it is naturally to have .indexOfMin But I disagree on specialized algorithms. Can't understand, how custom-made function with block with comparision is better than handful, clear and

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-18 Thread Matthew Johnson via swift-evolution
> On Apr 18, 2016, at 11:08 AM, Dmitri Gribenko wrote: > > On Sun, Apr 17, 2016 at 11:10 AM, Matthew Johnson via swift-evolution > wrote: >> These extension points are effectively “optional protocol requirements”. > > I'm sorry, but they are not

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread plx via swift-evolution
I *quite* like `extrema`/`indicesOfExtrema` over minmax. > On Apr 17, 2016, at 10:03 AM, Patrick Pijnappel > wrote: > > I like the idea. A few notes on naming: > – minIndex is somewhat confusing to me (it sounds like it's getting the > minimum index, i.e.

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread Patrick Pijnappel via swift-evolution
I like the idea. A few notes on naming: – minIndex is somewhat confusing to me (it sounds like it's getting the minimum index, i.e. indices.minElement()). How about indexOfMin() or indexOfMinElement()? – minmax() also doesn't read very well to me, plus it should technically be minMax() which is

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread plx via swift-evolution
I like the idea. It worries me a bit if the general recipe for such situations is to add dedicated-purpose methods like `_customIndexOfMinComparableElement` (etc.) to standard-library protocols; it *will* work, but is only going to work for the methods that get such treatment. If it were

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread Dmitri Gribenko via swift-evolution
On Sat, Apr 16, 2016 at 11:50 PM, Taras Zakharko via swift-evolution wrote: > Hi Nate, > > I think this is a very useful addition! I also had a related proposal few > days ago: > https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/014665.html > > I

Re: [swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread Taras Zakharko via swift-evolution
Hi Nate, I think this is a very useful addition! I also had a related proposal few days ago: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/014665.html I feel like min/max

[swift-evolution] [Draft] Expanded min/max algorithms

2016-04-17 Thread Nate Cook via swift-evolution
Hello all, Attached is a draft of a proposal to expand the min and max sequence APIs to better handle collections and to support future sorted sequences/collections. The proposal is in a gist here and inlined below—would