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 := slice.New([]byte{})
st.Push(1)
b := st.Pop()
st.Queue(b)
b = st.Dequeue()

st.Add(2)
st.DeleteIndex(0)
st.Add(7)
st.DeleteItem(7)

etc

On Fri, 5 Feb 2021, 10:45 Matthew Holiday, <matthew.holi...@nytimes.com>
wrote:

> See also this graphical cheat sheet:
> https://ueokande.github.io/go-slice-tricks/
>
> On Fri, Feb 5, 2021 at 2:09 AM Brian Candler <b.cand...@pobox.com> 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 existing ones do
>> the job.
>>
>> On Thursday, 4 February 2021 at 23:55:36 UTC selahad...@gmail.com wrote:
>>
>>> Hi,
>>> I wonder if there are any proposals for the Remove method for Slices,
>>> which removes an element from a Slice.
>>>
>>> Since the status of the latest generics draft is `likely accepted` and
>>> it'd be possible to implement this with `generics`. I believe such an
>>> addition to language would alleviate the need to `loop + swap + resize`
>>> each time, and enhance the overall readability since there is a consensus.
>>>
>>> This may seem trivial, but I want to highlight some examples from other
>>> langs just to further* concretize*:
>>> arraylist.remove(object o) => java
>>> list.remove(val) => python
>>> array.remove(at: 0) => swift
>>>
>>> I have looked for the proposals for Go 2 but couldn't find any regarding
>>> this issue.
>>>
>>> There are obviously more things to consider, like whether the operation
>>> should keep the order.
>>>
>>> I'd be very happy with your responses to this pseudo-proposal.
>>>
>>> --
>> 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/e43d26b0-d259-43e6-aa3b-f52f22f38556n%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/e43d26b0-d259-43e6-aa3b-f52f22f38556n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> *Matt Holiday*
> Senior Gopher, Marketing Technologies
>
> 620 Eighth Avenue
>
> New York, NY 10018
>
> matthew.holi...@nytimes.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/CAGSa1CkCLkiAFUfiuwWwT8m18qj9Sn2_Q6HQVn54GKKD7Ydh2g%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CAGSa1CkCLkiAFUfiuwWwT8m18qj9Sn2_Q6HQVn54GKKD7Ydh2g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAE%3DAWBXscE092cKHyo4bp4SrLoB9HTk%3DyY8-D%3DqMUCCRf5WfsQ%40mail.gmail.com.

Reply via email to