cells 0/1/2 are used for if/else condition
+ set 1 to cell #0
> leave 0 in cell #1
> leave 0 in cell #2
> ++++ +++ initialize counter (cell #3) to 7
[ use loop to set next four cells to 14/0/49
> ++ add 2 to cell #4
> leave 0 in cell #5 (navigation stop condition)
> ++++ +++ add 7 to cell #6
<<< - decrement counter at cell #3
]
>- set cell #4 to 13 (newline)
<, input main loop counter value into cell #3
[ if main loop counter is not 0
if direction cell in #0 is 1 then print sequence forward; otherwise print backward
<[-] set #2 cell value to 0
<[-]+ set #1 cell value to 1
< navigate pointer to #0
[ if #0 is 1 then (part of if/else construction)
>>>>>> navigate to the start of the sequence at #6
[.>] print the sequence forward
<[<] navigate back to #5
<<<<- navigate to #1 and set it to 0 to exit condition block (part of if/else construction)
]> (part of if/else construction) exit at #1 and navigate to #2 or exit at #0 and navigate to #1
[ else (entry position at #1)
>>>>> navigate to the sequence start at #6
[>] navigate to the last sequence element
<[.<] print the sequence backward; end at #5
<<<<-> navigate to #1;set it to 0 and navigate to #2 (part of if/else construction)
]<< end if; go back to #0 (part of if/else construction)
as a result of if/else both #1 and #2 must be 0
inverse value at #0 (1 to 0 / 0 to 1)
[>+<[-]] if #0 is true (is not 0) then set #1 to 1 and #0 to 0
+ increment value at #0
>[<->-] if #1 is true (is not 0) then set #0 to 0 and #1 to 0
inverse ends on #1
>>>. print newline taken from #4
append new element to the end of the sequence
>> go to the sequence start at #6
[>] navigate to sequence end
append 45 (minus) to the end of the sequence
> +++++ set 5 to cell at the left; temporary counter
[ helper calculating 5*9 loop
< +++++ ++++ append 9 to the cell at the right
>- decrement temporary counter
]
append the new element = previous element plus 1
<< use previous cell as counter
[
>> + go to the current cell and increment its value
> + also make a copy to the cell at the right
<<< - decrement counter
]
>>+ increment the new value in the end of the sequence
> copy value back to the previous cell in the sequence; use copy in the cell at the right as counter
[
<<<+ increment value in the previous cell
>>>- decrement counter value
]
<[<] put pointer to the beginning of the sequence (cell #6)
<<- decrement main loop counter in cell #3
]