On Sat, Feb 6, 2021 at 8:01 PM Axel Wagner
wrote:
> FTR, I think even a library function that is defined as "the equivalent of
> `append(a[:i], a[j:]...)`" (for example) would provide value.
Yes, but IMO a net negative value. Many people will then mindlessly
just use this O(n) variant even thou
FTR, I think even a library function that is defined as "the equivalent of
`append(a[:i], a[j:]...)`" (for example) would provide value.
That being said, I also think having this discussion now seems pointless.
Any of it will clearly not happen before generics land (or are rejected),
which is still
On Sat, Feb 6, 2021 at 5:36 PM Sean wrote:
> I think there is definitely a need for a built-in "remove" function for
> arrays and slice.
> Everyone is writing their own implementation for this, it is both confusing
> and "x = append(a[:x], b[x:])" like blablabla is not readable.
Please define
it may be useful to avoid repetition, for example if implementing stacks,
you have to create the "pop(), push(), top()" before starting to code what
you want.
Maybe there's place for this utility functions under the "container/"
package (like "container/slice"), where you could do things like:
st
On Fri, Feb 5, 2021 at 3:46 PM Fernando Meyer wrote:
> I understand the pragmatism behind having or not features in the language and
> its standard library. But, almost all the golang projects I've worked with
> implement their own utility function to remove elements from a slice,
> sometimes
On Fri, Feb 5, 2021 at 6:46 AM Fernando Meyer wrote:
> I understand the pragmatism behind having or not features in the language
> and its standard library. But, almost all the golang projects I've worked
> with implement their own utility function to remove elements from a slice,
> sometimes wit
I understand the pragmatism behind having or not features in the language and
its standard library. But, almost all the golang projects I've worked with
implement their own utility function to remove elements from a slice, sometimes
with order in place, others not. Mostly always these home-brewe
See also this graphical cheat sheet:
https://ueokande.github.io/go-slice-tricks/
On Fri, Feb 5, 2021 at 2:09 AM Brian Candler wrote:
> See: https://github.com/golang/go/wiki/SliceTricks#delete
> (and lots of other neat tricks there).
>
> There's no need to add new syntax or functions when the ex
You could imagine a `slices` standard library package that has a regular
generic function called `slices.Remove` that removes one or a series of
elements. This seems like a smart addition to me, as the current de-facto
method isn't very expressive. I imagine this didn't exist before
because adding