Skip to content

Commit

Permalink
Add Remove All Whitespace in Brainfuck (#3673)
Browse files Browse the repository at this point in the history
* Add Remove All Whitespace in Brainfuck

* Clean up formatting

* Clean up comments
  • Loading branch information
rzuckerm authored Dec 22, 2023
1 parent 4a1b565 commit d38542c
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions archive/b/brainfuck/remove-all-whitespace.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[
Source for error message text:
https://copy.sh/brainfuck/text.html
]
; Mem 0 = 1 (indicate no input)
+
; Mem 1 = input; Loop while input not null
>,[
; Mem 0 = 0 (indicate input)
<[-]
; Mem 2 = input; Mem 3 = input; Mem 1 = 0
>>[-] ; Mem 2 = 0
>[-] ; Mem 3 = 0
<<[
>+ ; Inc Mem 2
>+ ; Mem Mem 3
<<- ; Dec Mem 1
]
; Sub 9 from Mem 3; If not zero (not tab)
>>---------[
; Dec Mem 3; If not zero (not newline)
-[
; Sub 3 from Mem 3; If not zero (not carriage return)
---[
; Sub 19 from Mem 3; If not zero (not space)
>+++[ ; Mem 4 = 3
<------ ; Sub 6 from Mem 3
>- ; Dec Mem 4
]
<- ; Dec Mem 3
[
; Display input (Mem 2) and reset Mem 3
<.
>[-]
]
]
]
]
; Mem 1 = input
<<,
]
; If no input; display error message
<[
[-]
-[--->+<]>.
+[--->+<]>+.
++[->+++<]>++.
++++++.
--.
+++[->+++<]>++.
[-->+<]>+++.
[-->+++++++<]>.
----.
-------.
----.
--[--->+<]>--.
++++[->+++<]>.
--[--->+<]>-.
[-->+++++++<]>.
++.
---.
+++++++.
[------>+<]>.
-----.
+.
--[--->+<]>-.
[->+++<]>+.
-[->+++<]>.
---[->++++<]>-.
+.
--.
---------.
+++++.
-------.
[-]
]

0 comments on commit d38542c

Please sign in to comment.