CT Busy Beaver

bearophile bearophileHUGS at lycos.com
Sun Aug 19 07:07:40 PDT 2012


Ali Çehreli:

> Took me a while! Phew... :)
>
>   http://dpaste.dzfl.pl/6b362382

I have back-ported your changes to my version, and it works (with 
few improvements, a larger Busy Beaver, etc):

http://dpaste.dzfl.pl/0791bea9

-----------------------

I have also tried to replace your code like this:

struct TypeListToArray(node : Cons!(value, tail), int value, 
tail) {
     void opCall(ref int[] output) {
         output ~= value;
         TypeListToArray!tail tl2v;
         tl2v(output);
     }

     static auto opCall() {
         TypeListToArray!node tl2v;
         return tl2v;
     }
}

struct TypeListToArray(node : Repeat!value, int value) {
     void opCall(ref int[] output) {
         output ~= value;
     }
}

import std.array;
void main() {
     import std.stdio;
     alias TuringMachine!(BusyBeaver2, Repeat!0, Repeat!0) tm;

     int[] tape1;
     TypeListToArray!(tm.finalLeft)()(tape1);
...


With a shorter template like:

template TypeListToArray(Node) {
     static if (is(Node Repeat : Repeat!value, int value))
         enum TypeListToArray = [value];

     static if (is(Node Cons : Cons!(value, Tail), int value, 
Tail))
         enum TypeListToArray = [value] ~ 
TypeListToArray!(Node.tail);
}

import std.array;
void main() {
     import std.stdio;
     alias TuringMachine!(BusyBeaver2, Repeat!0, Repeat!0) tm;

     enum tape1 = TypeListToArray!(tm.finalLeft);
...

But it's not working. Do you know why?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list