Talk:Ja

From Esolang
Jump to navigation Jump to search

Interpreter

Here is a little interpreter I made in javascript :

var code = prompt("Code ? (j and a only)");
var carac = 0;
var tab = [];
var zone = 0;
while (code.substr(carac, 1) != "") {
if (code.substr(carac, 1) == "j") {
if (tab[zone] != undefined) {
carac = tab[zone] - 1;
zone = tab[zone];
}
else {
tab[zone] = 0;
zone = 0;
carac = -1;
}
}
else if (code.substr(carac, 1) == "a") {
if (tab[zone] != undefined) {
tab[zone] = tab[zone] + 1;
}
else {
tab[zone] = 1;
}
}
carac += 1;
}
document.write(tab);

--Rerednaw (talk) 22:59, 31 January 2020 (UTC)

The definition doesn't match the example

As written, the j command sets both the IP and data pointer to the same value. This means that you can't write cells whose indexes are larger than the length of the program (as it would just end). This in turn makes the language a finite state machine (because cells whose value has gone above the number of cells that exist can't be read), and in fact less powerful as it's impossible to write a nontrivial infinite loop (i.e. an infinite loop where memory does not have the exact same state on every iteration).

Are you sure that the definition of the language here is correct? --ais523 04:33, 2 July 2018 (UTC)