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++ {
chTail := make(chan []int) if i < hi-1 {
go intSets(chTail, lo+1, hi) chTail := make(chan []int)
for tail := range chTail { go intSets(chTail, i+1, hi)
ch <- append([]int{lo}, tail...) // lo + tail for tail := range chTail {
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