Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-29 Thread Dave Abrahams via swift-evolution
on Fri Apr 29 2016, Haravikk wrote: > Actually, the binary search proposal settled on a definition of a partition > point method (and probably a partition method as well) that provides the real > implementation details anyway, so these could go ahead as-is. That's

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-29 Thread Dave Abrahams via swift-evolution
on Thu Apr 28 2016, Jeff Hajewski wrote: > Dave - I think it boils down to a gap in communication. We were under the > impression that the goal was a pure extension of CollectionType, without > making > any requirements on Generator.Element (i.e., your requiring it

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-29 Thread Haravikk via swift-evolution
Actually, the binary search proposal settled on a definition of a partition point method (and probably a partition method as well) that provides the real implementation details anyway, so these could go ahead as-is. You’re right that the search methods themselves may prefer to wait, since

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-28 Thread Dave Abrahams via swift-evolution
on Thu Apr 28 2016, Jeff Hajewski wrote: > Thanks for bringing this back into the spotlight Pyry. A few of us have been > working on this issue here: > > https://github.com/lorenzoracca/Swift-binary-search > > However we have sort of stalled as we have been unable to

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-28 Thread Jeff Hajewski via swift-evolution
Thanks for bringing this back into the spotlight Pyry. A few of us have been working on this issue here: https://github.com/lorenzoracca/Swift-binary-search However we have sort of stalled as we have been unable to come up with a unary approach that Dave suggested using just Bool return values.

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-04-28 Thread Pyry Jahkola via swift-evolution
Bringing up this topic because it became relevant with Brent Royal-Gordon's "[Idea] Bringing the partial/total ordering distinction into Comparable ". If the `<=>` operator with a return type of a three-case `enum Order`, you can

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-28 Thread Dave Abrahams via swift-evolution
on Fri Mar 25 2016, Jeff Hajewski wrote: > Dave, > > I've been giving this approach a lot of thought (and have read everything > I've been able to find that you've written on the matter several times) and > am not convinced it will work. Implementing a lowerBound

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-25 Thread Jeff Hajewski via swift-evolution
Dave, I've been giving this approach a lot of thought (and have read everything I've been able to find that you've written on the matter several times) and am not convinced it will work. Implementing a lowerBound function is trivial with a unary operator. However, implementing an upperBound or

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-24 Thread Dave Abrahams via swift-evolution
on Tue Mar 15 2016, Nate Cook wrote: >> On Mar 15, 2016, at 1:58 PM, Lorenzo Racca via swift-evolution >> wrote: >> >>> On Mar 15, 2016, at 6:49 PM, Haravikk >>> >> > > >>>

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-19 Thread Jeff Hajewski via swift-evolution
Nate - I suppose that's really the crux of the matter here. I agree a binary predicate solves the problem, but is that the route we want to go? I think it makes sense, but is there a reason we should stick with a unary predicate? For some reason I had it in my mind that there was mention of

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-15 Thread Lorenzo Racca via swift-evolution
> On Mar 15, 2016, at 6:49 PM, Haravikk wrote: > >> On 15 Mar 2016, at 15:48, Lorenzo Racca > > wrote: >> >> I already knew the impossibility of applying such a predicate as “$0 == 3” >> and I actually

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-15 Thread Haravikk via swift-evolution
> On 15 Mar 2016, at 15:48, Lorenzo Racca wrote: > > I already knew the impossibility of applying such a predicate as “$0 == 3” > and I actually couldn’t quite figure out a solution. I thought so, and I don’t think there is a way to do it, my point was really just that

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-15 Thread Jeff Hajewski via swift-evolution
This is something I've been working on as well. The issue I've been stuck on is how we define the predicate and match the definitions of lower_bound and upper_bound from C++. It seems to me that the focus should be on these implementations, since once we have these a simple binary_search follows.

Re: [swift-evolution] [Proposal] Add Binary Search functions to SequenceType

2016-03-15 Thread Haravikk via swift-evolution
I’m not sure the documentation matches the .lowerBound() and .upperBound() behaviours accurately enough; it suggests that a bound will be found for a predicate “match”, however if my predicate is { $0 == foo } then these won’t actually work at all unless I get lucky and the middle element is a