Re: [go-nuts] strings: escape sequence translation

2021-09-06 Thread Kurtis Rader
On Mon, Sep 6, 2021 at 7:40 PM 'nadashin' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Why is the function in Go compiler that interprets escape sequences not
> available in Go's standard library?
>

It does. See https://pkg.go.dev/strconv#Unquote. Try this hastily thrown
together example:

package main

import (
"fmt"
"strconv"
)

func main() {
e := strconv.Quote("a\033\r\nb")
v, err := strconv.Unquote(e)
fmt.Printf("%v .%v. .%v.\n", err, e, v)
}


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-s6PKsyVw_CqrcD51n05peO6FeWECjc1u%3DJ4U0fpH3DA%40mail.gmail.com.


[go-nuts] strings: escape sequence translation

2021-09-06 Thread 'nadashin' via golang-nuts
Why is the function in Go compiler that interprets escape sequences not
available in Go's standard library?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/mJkpELs3pCKZbujhpG_91bDVuA4xvJQ3lJJg65izWfUsniava_6QTYjc9mnvCFVEYyGDzzfmNQ1Y6V4LtlnmMl9THB7XKDAHvjQ2IkoQGwY%3D%40protonmail.com.


Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-06 Thread Arnaud Delobelle
If the growing function is currently

f(x) = 2x for x < 1024
f(x) = x + x/4 otherwise

(Which I haven't checked), couldn't a simple way be to use e.g.

f(x) = 2xfor x < 1024
f(x) = x + x/4 + 768 otherwise

Then

f(1023) = 2046
f(1024) = 2048

So the function is monotonic (and kind of "smooth")

On Tue, 7 Sep 2021, 02:17 'Keith Randall' via golang-nuts, <
golang-nuts@googlegroups.com> wrote:

> I don't think this is an important thing to fix, but I agree it is a bit
> odd. If there's a simple way to restore monotonicity we'll consider it.
> A similar issue: https://github.com/golang/go/issues/41239
>
> On Sunday, September 5, 2021 at 8:59:01 AM UTC-7 jake...@gmail.com wrote:
>
>> You are 100% correct. I missed that value. oops
>>
>> On Sunday, September 5, 2021 at 10:16:08 AM UTC-4 arn...@gmail.com wrote:
>>
>>>
>>>
>>> On Sun, 5 Sep 2021, 14:59 jake...@gmail.com,  wrote:
>>> [...]
>>>
 In the example given  (https://play.golang.org/p/RJbEkmFsPKM
 ), the capacities *are 
 *"monotonically
 increasing", as no number in the second column is smaller than the one
 before it.

>>>
>>> Nitpick: that is not true.  I copy-pasted the output of the playground
>>> below.
>>>
>>> 0 8
>>> 100 208
>>> 200 416
>>> 300 640
>>> 400 896
>>> 500 1024
>>> 600 1280
>>> 700 1408
>>> 800 1792
>>> 900 2048
>>> 1000 2048
>>> 1100 1408 <-- at this point the new cap is less than for the previous row
>>> 1200 1536
>>> 1300 1792
>>> 1400 1792
>>> 1500 2048
>>> 1600 2048
>>> 1700 2304
>>> 1800 2304
>>> 1900 2688
>>>
>>> Regards,
>>>
>>> Arnaud
>>>
>>> On Sunday, September 5, 2021 at 7:02:43 AM UTC-4 kortschak wrote:

> On Sun, 2021-09-05 at 03:51 -0700, Brian Candler wrote:
> > I'm not sure you're clear about what "monotonically increasing"
> > means.
> >
> > Are you saying that there are some cases where append() results in
> > the allocated size of a slice *shrinking*? If so, please
> > demonstrate.
>
> I think he means that the cap of the appended slice is not a
> monotonically increasing function of the cap of the input slice.
>
> https://play.golang.org/p/RJbEkmFsPKM
>
>
> --
 You received this message because you are subscribed to the Google
 Groups "golang-nuts" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to golang-nuts...@googlegroups.com.

>>> To view this discussion on the web visit
 https://groups.google.com/d/msgid/golang-nuts/912453d5-2f2f-43b2-b65f-ce27e95752e9n%40googlegroups.com
 
 .

>>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/fa360f3d-e23c-4c07-9505-9f89bd155bb8n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAJ6cK1Zk2UcUz37Bcf-z_7wM8%3D3jKJpQvv2d5nE-vsTVVRjLAQ%40mail.gmail.com.


Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-06 Thread 'Keith Randall' via golang-nuts
I don't think this is an important thing to fix, but I agree it is a bit 
odd. If there's a simple way to restore monotonicity we'll consider it.
A similar issue: https://github.com/golang/go/issues/41239

On Sunday, September 5, 2021 at 8:59:01 AM UTC-7 jake...@gmail.com wrote:

> You are 100% correct. I missed that value. oops
>
> On Sunday, September 5, 2021 at 10:16:08 AM UTC-4 arn...@gmail.com wrote:
>
>>
>>
>> On Sun, 5 Sep 2021, 14:59 jake...@gmail.com,  wrote:
>> [...]
>>
>>> In the example given  (https://play.golang.org/p/RJbEkmFsPKM 
>>> ), the capacities *are 
>>> *"monotonically 
>>> increasing", as no number in the second column is smaller than the one 
>>> before it.
>>>
>>  
>> Nitpick: that is not true.  I copy-pasted the output of the playground 
>> below.
>>
>> 0 8
>> 100 208
>> 200 416
>> 300 640
>> 400 896
>> 500 1024
>> 600 1280
>> 700 1408
>> 800 1792
>> 900 2048
>> 1000 2048
>> 1100 1408 <-- at this point the new cap is less than for the previous row
>> 1200 1536
>> 1300 1792
>> 1400 1792
>> 1500 2048
>> 1600 2048
>> 1700 2304
>> 1800 2304
>> 1900 2688
>>
>> Regards,
>>
>> Arnaud
>>
>> On Sunday, September 5, 2021 at 7:02:43 AM UTC-4 kortschak wrote:
>>>
 On Sun, 2021-09-05 at 03:51 -0700, Brian Candler wrote: 
 > I'm not sure you're clear about what "monotonically increasing" 
 > means. 
 > 
 > Are you saying that there are some cases where append() results in 
 > the allocated size of a slice *shrinking*? If so, please 
 > demonstrate. 

 I think he means that the cap of the appended slice is not a 
 monotonically increasing function of the cap of the input slice. 

 https://play.golang.org/p/RJbEkmFsPKM 


 -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/912453d5-2f2f-43b2-b65f-ce27e95752e9n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fa360f3d-e23c-4c07-9505-9f89bd155bb8n%40googlegroups.com.