30 Codels
Fibonacci generator. Prints out terms of the Fibonacci sequence to stdout and doesn't stop.
This is the first introduction of the roll
operator, as well as the first time that a region size bigger than 1 is used with the push
operator to get a specific value onto the stack.
As always starts in the top-left moving right. The first 2 operations push
a 1 onto the stack and then output
it since the Fibonacci sequence starts with two 1s, but the main program loop will only print 1 once. Then it push
es 2 more 1s onto the stack to end up in the dark magenta in the top-right to start the main program loop.
Moving down the right side we duplicate
and output
to print off the next term of the sequence, then duplicate
again to get a copy of the current sequence value. Moving left across the bottom executes 2 push
operations. Since the light red region in the bottom-right is 3 codels in size, the first push
will push a 3 onto the stack instead of a 1.
Moving up into the light blue is a roll
operation. This pops the top 2 values off of the stack and performs a number of rolls equal to the first value popped, to a depth equal to the second value popped. In this case, it will perform 1 roll to a depth of 3. A roll to depth n
takes the top value of the stack (our duplicated current value) and buries it n
places deep. Our stack is only 3 deep right now so it will bury the top value at the bottom.
Moving up once more performs an add
operation adding together the current sequence value with the previous sequence value. Our stack now has the next (new current) sequence value on top, and the last value below it. The program now moves right across the white into the dark magenta to start the loop again.
The yellow pattern in the middle is never used.