You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lately I've been using golang a lot for competitive programming, sometimes uses ruby (because of their awesome built-in combinatorial/permutation/prime/automatic-bignumber library). It would be nice if I could fully ditch C++ (especially the lower_bound/upper_bound/next_permutation function) by having Go implement those functions inside standard library as go 2.0 released, something like this:
// same as C++ STL's lower_bound, upper_bound
pos := slice.LowerBound(arr interface{},cmpFunc func(a,b int)int) // cmpFunc returns -1, 0 or +1
pos := slice.UpperBound(arr interface{},cmpFunc func(a,b int)int)
// similar to lower_bound, upper_bound but return nearest value from sorted slice, eg.
// for example: [1,4,5,6,10]
// when finding 3 NearestLowerBound = 0 (value=1) NearestUpperBound = 1 (value=4)
// when finding 9 NearestLowerBound = 4 (value=6) NearestUpperBound = 5 (value=10)
pos := slice.NearestLowerBound(arr interface{},cmpFunc func(a,b int)int)
pos := slice.NearestUpperBound(arr interface{},cmpFunc func(a,b int)int)
// same as C++ STL's next_permutation
haveNext := slice.NextPermutation(arr sort.Interface)
this surely will increase Go's adoption and attract more competitive programmers.
Why as Go 2.0, because some of the competitive programming/online judges still using old version of Go, so when they decided to upgrade to Go 2.0, batteries already included:
Currently we are hoping to add some form of generics to Go, in which case people will be able to write these functions themselves. For the current design draft, see https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md. I'm going to close this issue in favor of adding generics. We can revisit if generics wind up not being adopted.
lately I've been using golang a lot for competitive programming, sometimes uses ruby (because of their awesome built-in combinatorial/permutation/prime/automatic-bignumber library). It would be nice if I could fully ditch C++ (especially the lower_bound/upper_bound/next_permutation function) by having Go implement those functions inside standard library as go 2.0 released, something like this:
this surely will increase Go's adoption and attract more competitive programmers.
Why as Go 2.0, because some of the competitive programming/online judges still using old version of Go, so when they decided to upgrade to Go 2.0, batteries already included:
The text was updated successfully, but these errors were encountered: