Files
Dragon/main.bf

44 lines
1.4 KiB
Beef
Raw Normal View History

2025-09-15 10:07:24 +10:00
[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.]
2025-09-16 15:58:33 +10:00
[
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 |
>[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>] >[[>>]>]
2025-09-15 10:07:24 +10:00
2025-09-16 15:58:33 +10:00
>[>.>] Output
<<[[<<]<<]<<<<<<< Return to start
2025-09-15 10:07:24 +10:00
]
2025-09-16 15:58:33 +10:00
>-<[-] disable else flag
2025-09-15 10:07:24 +10:00
]
2025-09-16 15:58:33 +10:00
>+<[->]>[ 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)
2025-09-15 10:07:24 +10:00
]
2025-09-16 15:58:33 +10:00
<<, Return to cell 0; get next input and loop again
]