mitxela.com forum
Welcome. Please log in or register.

Stuck in loop Brainfuck.
Tearzz Posted: 27 Sep 2018, 11:38 PM
Avatar


Member
Posts: 5
Joined: 27-September 18
On the Wikipedia for Brainfuck, it says that to get all input until a newline character (ENTER / RETURN / ASCII: 10) you write:
----------[++++++++++,>----------]++++++++++
which makes sense. But in the infrabuck compiler it's stuck in the loop even though the value is 0.

I've been using this "IDE" (https://minond.xyz/brainfuck/), which also seems to get stuck in the loop even though the step is clearly on 0.

-------------
[top]
mit Posted: 28 Sep 2018, 12:01 AM
Avatar
yeah whatever

Admin
Posts: 532
Joined: 4-May 16
That code looks right. This is almost certainly a Windows line-ending thing. Linux uses ASCII 10 for line endings (noted as \n), windows uses two bytes for line endings, ASCII 13 and ASCII 10 (noted as \r\n). The online interpreter is probably getting confused, because javascript has been butchered to use a hybrid of line endings. The compiled program is probably struggling because the windows terminal is not passing the line endings through.

You can check it's working by waiting for a different character instead, e.g. a space (which is ASCII 32).

,--------------------------------[++++++++++++++++++++++++++++++++>, --------------------------------]++++++++++++++++++++++++++++++++

I just looked at the javascript interpreter you linked to, it's using a prompt window to accept input, so it's not even possible to type a carriage return there at all.

-------------
[top]
Tearzz Posted: 28 Sep 2018, 06:32 AM
Avatar


Member
Posts: 5
Joined: 27-September 18
When I press ENTER it has the value 10. I know that because when I added 39 to it
+++[->+++++++++++++<]
it gave me the ASCII character 1 (#49). But I still get stuck in the loop if I just press ENTER.

-------------
[top]
Tearzz Posted: 28 Sep 2018, 08:35 AM
Avatar


Member
Posts: 5
Joined: 27-September 18
I found a way to do that I personally would consider to look way cooler.

+[>+,<->]<[<]>[+.>]


EDIT: That's only in the interpreter https://minond.xyz/brainfuck/, this wouldn't actually work with a compiler.

Last edit by Tearzz at 28 Sep 2018, 08:59 AM

-------------
[top]
mit Posted: 28 Sep 2018, 10:42 AM
Avatar
yeah whatever

Admin
Posts: 532
Joined: 4-May 16
You have a typo in your code in the first post.

----------[++++++++++,>----------]++++++++++

should be
----------[++++++++++>,----------]++++++++++

You're taking input from the keyboard then moving over immediately, ignoring what was typed.

PS using my interpreter it's easy to type a carriage return to enter ascii 10. Not quite as pretty though, I admit.

-------------
[top]

Sign in to post a reply.