44 lines
1.4 KiB
Brainfuck
44 lines
1.4 KiB
Brainfuck
[All data is stored in chunks of 2 bytes/cells: the first cell is the type and the second cell is the data.
|
|
|
|
For example: The integer 27 would be stored as | 1 | 27 | 0 | 0 |. Note the double zero at
|
|
the end of the data.]
|
|
|
|
[
|
|
If... else... logic: [if>-<[-]]>+<[->]>[else]
|
|
]
|
|
|
|
,[
|
|
|
|
-------------------------------------------------------------------------------------------------------------------
|
|
|
|
[ if $input !== 's'
|
|
|
|
++++[ if $input !== 'o'
|
|
|
|
>-<[-] disable else flag
|
|
]
|
|
|
|
>+<[->]>[ if $input === 'o'
|
|
$$$ Cells: | 0 | (1) | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | data |
|
|
->,------------------------------------------------[[>+<-]>-]
|
|
If input2 = 0: | 0 | 0 | (0) | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | data |
|
|
If input2 = 9: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (0) | data |
|
|
>[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>]
|
|
|
|
>[>.>] Output
|
|
<<[[<<]<<]<<<<<<< Return to start
|
|
]
|
|
|
|
|
|
>-<[-] disable else flag
|
|
]
|
|
|
|
>+<[->]>[ If input === 's'
|
|
->>>>>>>>>>>[[>>]>>]< Go to next empty data space
|
|
----------[++++++++++>+++>,----------] Store string there; exit loop when input === '\n'
|
|
<[-]<<[[<<]<<]<<<<<< Return to cell 2 (same as the if loop)
|
|
]
|
|
|
|
<<, Return to cell 0; get next input and loop again
|
|
|
|
] |