Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
removing one slice elements from another
95 views
Skip to first unread message
Jabari Zakiya
unread,
Feb 12, 2025, 2:27:36 PM
Feb 12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I have two slice, lhr and lhr_dels.
I want to remove everything in lhr_dels from lhr.
I tried these:
lhr = slices.DeleteFunc(lhr, func(n uint) []uint { return lhr_del})
or
lhr = slices.Delete(lhr, lhr_del)
and can't figure out from the error messages|docs how to fix it.
Can someone set me straight on how to do this?
Thanks in advance.
Def Ceb
unread,
Feb 12, 2025, 2:32:27 PM
Feb 12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
The function passed to DeleteFunc should accept a single element and
return a boolean indicating whether it should be removed.
You could do this:
lhr = slices.DeleteFunc(lhr, func(n uint) bool { return
slices.Contains(lhr_del, n) })
Jabari Zakiya:
> --
> 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
<mailto:
golang-
>
nuts+uns...@googlegroups.com
>.
> To view this discussion visit
https://groups.google.com/d/msgid/golang-
> nuts/8d5189c9-a1ba-44c5-a62f-3fa8eecc72cbn%
40googlegroups.com
<https://
>
groups.google.com/d/msgid/golang-nuts/8d5189c9-a1ba-44c5-
> a62f-3fa8eecc72cbn%
40googlegroups.com?utm_medium=email&utm_source=footer
>.
Jabari Zakiya
unread,
Feb 12, 2025, 3:12:01 PM
Feb 12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Thanks!
That did it.
Reply all
Reply to author
Forward
0 new messages