Reputation: 6592
I can't find if it is or not and am very curious - if it doesn't qualify, what functionality does it lack to qualify? I have done a decent amount of batch and don't see any obvious slip-ups in ability.
Upvotes: 24
Views: 5856
Reputation: 1726
I've just 'proven' batch is turing complete, by creating a brainfuck interpreter in batch (Because brainfuck is proven to be Turing complete):
https://github.com/yyny/Brainfuck-In-Batch
By the way, a turing complete programming language means its either:
true
to false
and the other way around is still valid. In the case of batch: SET A=5
)array[index];
.)IF %A%==0 GOTO LABEL
(Jump to label if A is zero), while (var) {/*code*/}
(Jump back to start of code while var is not zero) or jmp0 exit;
(Jump to exit if the current value on the stack is zero))The traditional Turing machine requires you to have a tape which is infinite on both sides, but a simple array, string, table (object) or binary number (bitfield) will work too. In my "Brainfuck in Batch" for example I used a array/table-like object to store the memory (Since batch allows you to change the key of a value, like so: SET ARRAY[%KEY%]=%VALUE%
)
Upvotes: 28
Reputation: 13196
I believe it qualifies. The basic requirements of Turing completeness are thought to be reducible to a few simple operations, including: the ability to store state (variables), the ability to branch (conditionals), and the ability to iterate (loops). Batch has all of these, so unless there is some as-yet-undiscovered requirement for Turing completeness, batch scripting qualifies.
Upvotes: 16