how to use *recursion* to generate binary code list. For example, binary(3) will generate:
000
001
010
011
100
101
110
111
I was thinking using this: in the above example, the last column 0 and 1 flipping by interval 1, the middle column 0 and 1 flip by interval 2, etc. So that it is possible to program recursively in terms of column-wise. It has advantage that it is possible to manipulate each column, eg., instead of changing flipping pattern from "0->1" to "1->", etc. So if this approach resolved, other pattern can be done similarly too.
However, I am not satisfied by this approach: it requires a lot of memory storage before the real output. All columns have to be stored in order to display the results. When the number of bits getting larger, that is no good. So there should be a way to do it row-wise.
It should have a easier way to do that recursively.
000
001
010
011
100
101
110
111
I was thinking using this: in the above example, the last column 0 and 1 flipping by interval 1, the middle column 0 and 1 flip by interval 2, etc. So that it is possible to program recursively in terms of column-wise. It has advantage that it is possible to manipulate each column, eg., instead of changing flipping pattern from "0->1" to "1->", etc. So if this approach resolved, other pattern can be done similarly too.
However, I am not satisfied by this approach: it requires a lot of memory storage before the real output. All columns have to be stored in order to display the results. When the number of bits getting larger, that is no good. So there should be a way to do it row-wise.
It should have a easier way to do that recursively.