Commit a618da28 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c4f1909f
...@@ -339,11 +339,13 @@ func IntSets(N int) chan []int { ...@@ -339,11 +339,13 @@ func IntSets(N int) chan []int {
func intSets(ch chan []int, lo, hi int) { func intSets(ch chan []int, lo, hi int) {
ch <- []int{} // ø ch <- []int{} // ø
if lo < hi-1 { for i := lo; i < hi; i++ {
if i < hi-1 {
chTail := make(chan []int) chTail := make(chan []int)
go intSets(chTail, lo+1, hi) go intSets(chTail, i+1, hi)
for tail := range chTail { for tail := range chTail {
ch <- append([]int{lo}, tail...) // lo + tail ch <- append([]int{i}, tail...) // i + tail
}
} }
} }
...@@ -357,7 +359,12 @@ func TestIntSets(t *testing.T) { ...@@ -357,7 +359,12 @@ func TestIntSets(t *testing.T) {
} }
I := func(v ...int) []int { return v } I := func(v ...int) []int { return v }
want := [][]int{I(), I(0), I(1), I(2) /* XXX */} want := [][]int{I(),
I(0),
I(0,1), I(0,2), I(0,1,2),
I(1),
I(2),
}
if !reflect.DeepEqual(got, want) { if !reflect.DeepEqual(got, want) {
t.Fatalf("error:\ngot: %v\nwant: %v", got, want) t.Fatalf("error:\ngot: %v\nwant: %v", got, want)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment