Linus' idea of "good taste" code
Mark via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 26 07:10:31 PDT 2016
On Tuesday, 25 October 2016 at 22:53:54 UTC, Walter Bright wrote:
> It's a small bit, but the idea here is to eliminate if
> conditionals where possible:
>
> https://medium.com/@bartobri/applying-the-linus-tarvolds-good-taste-coding-requirement-99749f37684a#.nhth1eo4e
>
What would you say is the best way to write his "Initialize grid
edges" code in D? Ideally, I would like something like this:
void initEdges(int val, ref int[GRID_SIZE][GRID_SIZE] grid) {
map!(a => val)(chain(grid.row(0), grid.row($-1), grid.column(0),
grid.column($-1));
}
but multidimensional arrays don't have built-in primitives like
that (as far as I know).
More information about the Digitalmars-d
mailing list