A little of coordination for Rosettacode

bearophile bearophileHUGS at lycos.com
Fri Feb 15 18:34:45 PST 2013


A first revision, do you like the toString?

http://codepad.org/qhH2XpMx

- - - - - - - - - - -

The modified code contains still an enum that gets converted to 
char and then to int. I am not going to write code like that in 
my own "production code" :-)

- - - - - - - - - - -

To improve this type soup a bit I suggest to introduce one or 
more alias for the types of states, etc, like:

alias State = char;

and then use it/them.


static struct TuringMachine {
     char[] symbols;
     char blank;
     char initialState;
     char[] haltStates, runningStates;
     char[][string] rules;
     char[] input;
}

static struct TapeHead {
     const char[] symbols;
     const char blank;
     char[] tape;
     size_t index;
...

- - - - - - - - - - -

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list