func zip(patterns []*ast.Pattern) ([]*ast.Pattern, []int) { zipped := ast.Set(patterns) ast.Sort(zipped) indexes := make([]int, len(patterns)) for i, pattern := range patterns { indexes[i] = ast.Index(zipped, pattern) } return zipped, indexes }
func zip(patterns []*ast.Pattern) ([]*ast.Pattern, []int) { set := ast.Set(patterns) ast.Sort(set) if index := ast.Index(set, zipIgnoreSet[0]); index != -1 { set = ast.Remove(set, index) } if index := ast.Index(set, zipIgnoreSet[1]); index != -1 { set = ast.Remove(set, index) } indexes := make([]int, len(patterns)) for i, pattern := range patterns { index := ast.Index(set, pattern) if index == -1 { index = ast.Index(zipIgnoreSet, pattern) index *= -1 index -= 1 } indexes[i] = index } return set, indexes }