GitHub - dmac100/reversiblevm
An editor and virtual machine for a JavaScript like language that allows running a program backwards and forwards, with an animated graphical visualisation.
@delay(transition: 50, instruction: 2);
a = [7, 3, 1, 8, 4, 6, 2, 6, 2, 3, 8, 1, 10, 7, 3, 6, 2, 3, 8, 1];
a = a.map(x => { value: x });
@for(item <- a)
@rect(
x: 40,
y: 15 * a.indexOf(item) + 20,
width: 20 * item.value,
height: 8,
fill: a.indexOf(item) < x ? 'green' : 'red',
strokeWidth: 1,
stroke: '#333'
);
for(var x = 0; x < a.length(); x++) {
for(var y = x; y < a.length(); y++) {
if(a[x].value > a[y].value) {
@vizUpdatesOff;
var t = a[x];
a[x] = a[y];
a[y] = t;
@vizUpdatesOn;
}
}
}
java -jar reversiblevm.jar [-f filename] [-g] [-h] [filename]