Re: [go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread 'Axel Wagner' via golang-nuts
Sorry, the predicate should be var b T pred := func(a T) bool { return cmp(a, b) >= 0 } On Tue, Apr 5, 2022 at 7:27 AM Axel Wagner wrote: > Hm I must say, I also don't really understand removing the predicate-based > one. It is easy, when you have a comparison function, to get to a predicate: >

Re: [go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread 'Axel Wagner' via golang-nuts
Hm I must say, I also don't really understand removing the predicate-based one. It is easy, when you have a comparison function, to get to a predicate: pred := func(a, b T) bool { return cmp(a, b) >= 0 } But not the other way around, so a predicate is more general. I used the predicate version of

[go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread Sudhir Jonathan
The earlier method signature for slices.BinarySearchFunc was very useful: It was of the form ``` slices.BinarySearchFunc(array, func(e T) bool) ``` which returned the smallest index at which predicate would return true. This was incredibly useful to do inequality operation binary searches - l