RosettaCodeData/Task/Gray-code/D/gray-code-3.d

12 lines
237 B
D
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
import std.stdio, std.algorithm, std.range;
2013-10-27 22:24:23 +00:00
string[] g(in uint n) pure nothrow {
return n ? g(n - 1).map!q{'0' ~ a}.array ~
g(n - 1).retro.map!q{'1' ~ a}.array
2013-04-10 21:29:02 -07:00
: [""];
}
void main() {
2013-10-27 22:24:23 +00:00
4.g.writeln;
2013-04-10 21:29:02 -07:00
}