Talk:Jumplang
Jump to navigation
Jump to search
Turing-Completeness
Being a brainfuck derivative, a set of commands in Jumplang will match with valid brainfuck commands. The following commands are present in both languages.
- +
- -
- >
- <
- ,
- .
Note that [ and ] are not in Jumplang. Now, the following commands are exclusive to Jumplang.
- ^
- v
- ?
- !
Fortunately, the first 3 can be translated to brainfuck.
Jumplang | Brainfuck |
---|---|
^ | ++ |
v | -- |
? | [command>]<see concerns |
Why did I skip !
? Well, here’s my concerns.
- brainfuck only reads code in one direction, with [] being the exception, the problem is that brainfuck can’t tell the brackets to pick one specific location, thus, I believe that ! cannot be translated to brainfuck.
- In my ? translation to brainfuck, it requires the cell to the right to be clear, although this is less of a concern than 1.
That concludes my work.
--Emerald (talk) 22:20, 3 June 2020 (UTC)
- Your second concern is nothing to be, well, concerned about, as you can replace all >s with >>s and all <s with <<s, so as to leave a clear "skipping cell" to the right of every "value cell".
- Your first concern, that ! cannot be translated to BF, might not be entirely correct. We can use a version of BF with loops that loop on 0 instead of non-0. Let's try to translate the program
+[,.]
. First, we use a+>
to increment the first cell and then the CP. Now, we have to make the next cell store the index of the opening bracket [. Here's where we start to run into problems.
- For every + we add, the start of the loop gets one command further away, therefore having essentially no effect except for making the code unnecessarily longer, which is why I added the ^ and v commands: they let us actually get closer to the loop start. If we add 1 ^ command, the cell will contain 2, but the loop start will be at index 3; adding another ^ sets the current cell and the loop start both equal to 4. So far, our code is
+>^^<
.
- Now we can add the loop body:
<,.>
(the arrows to move the CP to/from the cell that tells us where to jump), making our code+>^^<,.>
. Now to end the loop, we can add a!
to jump to the loop start, so our code is+>^^<,.>!
— but that's not enough, as this is an infinite loop. We can, however, repeat the process of incrementing the cell telling us where to jump by 2, but this time on the loop end, and conditionally jump to the loop end using?!
on the first cell, then going to the first cell, catting (,.), and jumping back to before the start of the loop. With enough ^s to make up the loop start/end "jump cells", and the right <s and >s to correctly position the cells for each jump, it would perform a cat that loops on EOF (an interactive-IO interpreter returning 0 on EOF causes this to behave like a loop while no input program.
- The process described here can be extended to all loops, therefore Jumplang is Turing-complete. PythonshellDebugwindow (talk) 20:17, 4 June 2020 (UTC)
Minimization
Should we have a separate article on the minimized version of Jumplang? --Emerald (talk) 00:41, 20 June 2020 (UTC)
- I agree. "The minimization of Jumplang" is a long title. Will add now. PythonshellDebugwindow (talk) 12:52, 20 June 2020 (UTC)