Power set: Difference between revisions

Fixed bug with the powerset of larger sets returning duplicate subsets due to the edit in place semantics of append()
m (split a long line of elements of a group.)
(Fixed bug with the powerset of larger sets returning duplicate subsets due to the edit in place semantics of append())
Line 1,122:
var u set
for _, er := range r {
u = append(u, appendcopyAndAppend(er.(set), es))
}
r = append(r, u...)
}
return r
}
 
// regular append() will edit in place, creating duplicate subsets for larger set inputs
func copyAndAppend(slice []string, elem string) []string {
return append(append([]string(nil), slice...), elem)
}
 
Anonymous user