February 17, 2013
> so when you print the tape you trim the blanks away at both ends.

A wrong trimming code:


string toString() const {
    // Blank-stripped tape.
    const t2 = tape
               .find!(c => c != blank)()
               .retro()
               .find!(c => c != blank)()
               .retro();

    return format("...%(%)...", t2.empty ? [blank] : t2)
           ~ '\n'
           ~ format("%" ~ text(position + 4) ~ "s", "^")
           ~ '\n';
}


It gives:

Busy beaver machine (3-state, 2-symbol):
...0...
   ^
...1...
    ^


The second line should show the cell up to the head position:

Busy beaver machine (3-state, 2-symbol):
...0...
   ^
...10...
    ^


There are many ways to improve this program, like trimming away the blanks correctly, but I think the code is acceptable now:

http://rosettacode.org/wiki/Universal_Turing_machine#D

Bye,
bearophile
February 19, 2013
The chirality of the given output on Langtons ant  doesn't match what
the code produces. (That's because somebody changed it a while ago).
See also the talk page.

http://rosettacode.org/wiki/Langton%27s_ant#D
February 19, 2013
Jos van Uden:

> The chirality of the given output on Langtons ant  doesn't match what the code produces.

OK. I have changed the first entry.

Bye,
bearophile
February 22, 2013
Somebody added an incorrect notice to the D entry for Dijkstra's algorithm.
http://rosettacode.org/mw/index.php?title=Dijkstra%27s_algorithm&diff=next&oldid=147068
February 22, 2013
Jos van Uden:

> Somebody added an incorrect notice to the D entry for Dijkstra's algorithm.

The task requires a directed graph:

1. Implement a version of Dijkstra's algorithm that computes a shortest path from a start vertex to an end vertex in a directed graph.

So I have fixed the graph.

Bye,
bearophile
February 25, 2013
You have recently added:

http://rosettacode.org/wiki/Parse_command-line_arguments#D
http://rosettacode.org/wiki/Old_Russian_measure_of_length#D
http://rosettacode.org/wiki/Truth_table#D

But maybe there is one more Task you have recently added that I have missed.

Bye,
bearophile
February 25, 2013
On 25-2-2013 22:54, bearophile wrote:
> You have recently added:
>
> http://rosettacode.org/wiki/Parse_command-line_arguments#D
> http://rosettacode.org/wiki/Old_Russian_measure_of_length#D
> http://rosettacode.org/wiki/Truth_table#D

Yes.

> But maybe there is one more Task you have recently added that I have missed.

You can always click on "contribs" to get a better overview.


February 26, 2013
> http://rosettacode.org/wiki/Truth_table#D

Some changes:
http://codepad.org/PEZWmrHG

But it's not good enough yet :-) Maybe there are ways to produce a D version closed to the Go one.

Bye,
bearophile
February 26, 2013
On 26-2-2013 5:19, bearophile wrote:
>> http://rosettacode.org/wiki/Truth_table#D
>
> Some changes:
> http://codepad.org/PEZWmrHG
>
> But it's not good enough yet :-) Maybe there are ways to produce a D version closed to the Go one.


I would have prefered to write:


bool xor(in bool A, in bool B) pure nothrow
    return A != B;
}

But I couldn't figure out how to expand the boolean array to
an argument list. The Go example uses runtime reflection,
I believe.

Nice touch with the map, I still think in loops :)

February 26, 2013
Jos van Uden:

> But I couldn't figure out how to expand the boolean array to
> an argument list.

I wrote a version, it's more statically type safe, but the code is quite hairy, and the foreach(i) generates too many templates if the predicate has many bool arguments:

http://codepad.org/9Ar1pmMc

Are you able to improve it?


> The Go example uses runtime reflection, I believe.

I'd like a bit more reflection in D, to avoid a similar jungle of templates :-)


I think Rosettacode is currently down.

Bye,
bearophile