You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Utility functions like Intersect and IntersectFunc for slices packages will be handy for several cases.
// Intersect returns the common elements between two slices.funcIntersect[S~[]E](s1, s2S) (S~[]E) {
varresultSfor_, item:=ranges2 {
ifslices.Contains(s1, item) {
result=append(result, item)
}
}
}
// IntersectFunc returns the elements between two slices according to the functions.funcIntersectFunc[S~[]E, Ecomparable](s1, s2S, ffunc(s1, s2E) bool) S {
varresultSfor_, item:=ranges2 {
for_, subItem:=ranges1 {
iff(subItem, item) {
result=append(result, item)
}
}
}
returnresult
}
The text was updated successfully, but these errors were encountered:
Proposal Details
Utility functions like
Intersect
andIntersectFunc
forslices
packages will be handy for several cases.The text was updated successfully, but these errors were encountered: