Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-18 Thread howardcshaw
My most common use case for reversing strings has not come up in Go yet - basically, some languages provide a string search function that finds a character or substring starting from the beginning of the string. For example, in T-SQL, CharIndex. If they do not provide a corresponding search tha

Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-17 Thread 'Axel Wagner' via golang-nuts
Hi, On Sat, Feb 15, 2020 at 6:13 PM Amarjeet Anand wrote: > I need it quite often, maybe because of the kind of project am working on > currently. > I'd be super curious what that is. TBH, given how frequently this has come up, I've been wrecking my brain trying to figure out what people need i

Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-15 Thread roger peppe
One reason for not implementing it in the standard library is that there are many possible implementations. Do you want to reverse combining character sequences for example? Unicode is a complex beast and I suspect that reversing a string rune-by-rune may easily break important semantics. Is it eve

Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-15 Thread Amarjeet Anand
Thanks ian for the quick reply. As far as other languages are concerned, Like Java, stringBuilder.reverse() seems a logical place to put this feature. Because string builder gives us facility to generate a string, overcoming the limitation of string immutability. What if I want to generate a strin

Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-15 Thread Ian Lance Taylor
On Sat, Feb 15, 2020 at 8:37 AM Amarjeet Anand wrote: > > I was wondering why isn't there built-in string reverse function. Is it left > intentionally because of some reason? > > Although strings are immutable in go, there are multiple ways to achieve this > pretty easily. But having this functi

[go-nuts] Why isn't there strings.reverse("str") function?

2020-02-15 Thread Amarjeet Anand
Hi I was wondering why isn't there built-in string reverse function. Is it left intentionally because of some reason? Although strings are immutable in go, there are multiple ways to achieve this pretty easily. But having this function inbuilt will save our time because we need it quite often. -