I'd be grateful if people could give me an example to help me understand
the generics draft.  Suppose I've got these two functions:

     func MemberInt(x int, a []int) bool {
         for _, v := range a {
               if v == x {
                    return true
               }
         }
         return false
     }

     func MemberIP(x net.IP, a []net.IP) bool {
         for _, v := range a {
             if v.Equal(x) {
                 return true
             }
         }
         return false
     }

I can see how to write a generic "Member" function that takes an extra
equality predicate; but is there a way to write a function that
generalises both functions above without requiring the extra parameter?

Thanks.

-- 
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/87v9hytrcn.fsf%40pirx.irif.fr.

Reply via email to