Guest User

Untitled

a guest
Jun 2nd, 2010
250
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cells 0/1/2 are used for if/else condition
  2. +                    set   1 to cell #0
  3. >                    leave 0 in cell #1
  4. >                    leave 0 in cell #2
  5. > ++++ +++             initialize counter (cell #3) to 7
  6. [                    use loop to set next four cells to 14/0/49
  7.    > ++                 add   2 to cell #4
  8.    >                    leave 0 in cell #5 (navigation stop condition)
  9.     > ++++ +++           add   7 to cell #6
  10.    <<< -                decrement counter at cell #3
  11. ]                    
  12. >-                   set cell #4 to 13 (newline)
  13. <,                   input main loop counter value into cell #3                  
  14. [                    if main loop counter is not 0
  15.    if direction cell in #0 is 1 then print sequence forward; otherwise print backward
  16.    <[-]                 set #2 cell value to 0
  17.     <[-]+                set #1 cell value to 1
  18.    <                    navigate pointer to #0
  19.     [             if #0 is 1 then (part of if/else construction)
  20.       >>>>>>             navigate to the start of the sequence at #6
  21.       [.>]               print the sequence forward
  22.       <[<]               navigate back to #5
  23.       <<<<-              navigate to #1 and set it to 0 to exit condition block (part of if/else construction)
  24.     ]>                   (part of if/else construction) exit at #1 and navigate to #2 or exit at #0 and navigate to #1
  25.     [             else   (entry position at #1)
  26.       >>>>>              navigate to the sequence start at #6
  27.       [>]                navigate to the last sequence element
  28.       <[.<]              print the sequence backward; end at #5
  29.       <<<<->             navigate to #1;set it to 0 and navigate to #2 (part of if/else construction)
  30.     ]<<           end if; go back to #0 (part of if/else construction)
  31.     as a result of if/else both #1 and #2 must be 0
  32.  
  33.    inverse value at #0 (1 to 0 / 0 to 1)
  34.    [>+<[-]]      if #0 is true (is not 0) then set #1 to 1 and #0 to 0
  35.     +             increment value at #0  
  36.    >[<->-]       if #1 is true (is not 0) then set #0 to 0 and #1 to 0
  37.    inverse ends on #1
  38.  
  39.     >>>.              print newline taken from #4
  40.    
  41.    append new element to the end of the sequence                
  42.        >>                   go to the sequence start at #6
  43.        [>]                  navigate to sequence end
  44.        
  45.        append 45 (minus) to the end of the sequence
  46.        > +++++              set 5 to cell at the left; temporary counter
  47.        [                    helper calculating 5*9 loop
  48.            < +++++ ++++         append 9 to the cell at the right
  49.            >-                   decrement temporary counter
  50.        ]
  51.  
  52.        append the new element = previous element plus 1
  53.        <<                   use previous cell as counter
  54.         [
  55.            >> +             go to the current cell and increment its value
  56.           >  +             also make a copy to the cell at the right
  57.            <<< -            decrement counter
  58.        ]
  59.        >>+                  increment the new value in the end of the sequence
  60.        >                    copy value back to the previous cell in the sequence; use copy in the cell at the right as counter  
  61.        [
  62.            <<<+             increment value in the previous cell
  63.            >>>-             decrement counter value
  64.        ]
  65.    <[<]             put pointer to the beginning of the sequence (cell #6)
  66.    <<-              decrement main loop counter in cell #3
  67. ]
RAW Paste Data