On 5-2-2013 23:44, bearophile wrote:
Jos van Uden:

Partial translation of the universal_turing_machine-Ruby:
http://codepad.org/nUXLzAg2

I'd have to first read up on the subject.

It's a simple task, just to implement an universal Turing machine. It's a 
matter of finding a balance between the too much high level Ruby version and a 
too much C-like version.
In D a simple way to implement a tape is with two dynamic arrays, one represents all the 
cells on the right to the starting position, and the other array is used 
"inverted",
to represent all the cells on the left of the right position. There are faster 
solutions, but this is enough for the purposes of Rosettacode.

The Universal Turing Machine is working. I've only tested
with the given tables. I'll try some more tomorrow.

I couldn't get the AA's to nest the way they do in Ruby, so
I had to do it differently.

This task seemed like a good candidate for using an invariant,
but the loop in the run method already checks the state on
every iteration, so I'm not sure what you could check except
to see if all the fields have been initialized perhaps.

It was a fun task.

http://dpaste.dzfl.pl/3caa52e7

Reply via email to