On Thursday, 13 October 2016 at 19:06:26 UTC, Karabuta wrote:
I assume the purpose for those demonstrations are to win the
interest of the user as to how easy and clean D code can be.
// Round floating point numbers
import std.algorithm, std.conv, std.functional,
std.math, std.regex, std.stdio;
alias round = pipe!(to!real, std.math.round, to!string);
static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;
// Replace anything that looks like a real
// number with the rounded equivalent.
.map!(l => l.replaceAll!(c => c.hit.round)
How is a new visitor supposed to know "!" is for templates and
not some complicated syntax?
I agree, something friendly and familiar would be called for.
Instead we have weird float-rounding programs.
The goal of such program should be to push the reader to continue
reading by apealing to familiarty. I think this strongly conveys
the message that D is complicated and "not for me".
Do you notice something? The language branded as "simple" have
the simplest landing page programs.