Added outputs
This commit is contained in:
58
main.bf
58
main.bf
@@ -3,28 +3,42 @@
|
|||||||
For example: The integer 27 would be stored as | 1 | 27 | 0 | 0 |. Note the double zero at
|
For example: The integer 27 would be stored as | 1 | 27 | 0 | 0 |. Note the double zero at
|
||||||
the end of the data.]
|
the end of the data.]
|
||||||
|
|
||||||
# Get the first input by the user and check its type
|
[
|
||||||
,[-------------------------------------------------------------------------------------------------------------------
|
If... else... logic: [if>-<[-]]>+<[->]>[else]
|
||||||
$$$ Cells: | subtract $input 115 |
|
|
||||||
[ If $input !== 's'
|
|
||||||
++++[ If $input !== 'o'
|
|
||||||
|
|
||||||
]
|
|
||||||
>+<[>-]>[ If $input === 'o'
|
|
||||||
$$$ Cells: | 0 | (1) | ~~~~ | data
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
,[
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[ 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
|
||||||
|
|
||||||
]
|
]
|
||||||
>+<[>-]>[ If $input === 's' (direct translation: set up else flag; if subtract $input s:ascii !== 0 remove else flag)
|
|
||||||
$$$ Cells: | 0 | (1) |
|
|
||||||
Actual Data starts at cell #10: go to cell 10 then continue to next un
|
|
||||||
>>>>>>>>>>>[[>>]>>]<[-]---------- Subtract 10 to calibrate loop
|
|
||||||
[++++++++++>[-]+++>, Start loop; add 10 (to undo the end of loop and add data)
|
|
||||||
---------- Check if input is 10 (newline)
|
|
||||||
]
|
|
||||||
]<[-]
|
|
||||||
If $input = s : $$$ | 0 | 1 | ~~~~ | 3 | char1 | 3 | char2 | ~~~~ | 3 | charlast | (0) | 0 |
|
|
||||||
If $input != s: $$$ | subtract $input 115 | 0 | (0) |
|
|
||||||
Realign Cursor
|
|
||||||
<[[[<]<]>[<]>[<]>[<]>[<]>[<]>[<]>[<]>[<]>[<]>[<]<<]<<<<<<<<[-]<,]
|
|
@@ -4,4 +4,4 @@ Dragon is a coding langauge entirely interpreted in Brainfuck. It is designed wi
|
|||||||
|
|
||||||
### Inspiration
|
### Inspiration
|
||||||
|
|
||||||
Dragon is heavily inspired by Ground. Like Ground, it has simple syntax, and is relatively easy to learn. However, unlike Ground, no one ever will have a reason to use this
|
Dragon is heavily inspired by Ground. Like Ground, it has simple syntax, and is relatively easy to learn. However, unlike Ground, no one ever will have a reason to use this.
|
@@ -5,3 +5,9 @@
|
|||||||
Creates a string. Cannot create strings with a newline in them, but they can include null terminators (but why?).
|
Creates a string. Cannot create strings with a newline in them, but they can include null terminators (but why?).
|
||||||
|
|
||||||
Example usage (create string "Dingus"): `sDingus`
|
Example usage (create string "Dingus"): `sDingus`
|
||||||
|
|
||||||
|
### o
|
||||||
|
|
||||||
|
Outputs a string.
|
||||||
|
|
||||||
|
Example usage (output the 3rd created string, second index): `o2`
|
Reference in New Issue
Block a user