Multiplication tables: Difference between revisions
Content added Content deleted
(Added Bracmat example) |
(Updated D entry) |
||
Line 868: | Line 868: | ||
=={{header|D}}== |
=={{header|D}}== |
||
{{trans|PicoLisp}} |
{{trans|PicoLisp}} |
||
⚫ | |||
<lang d>import std.stdio, std.array, std.range, std.algorithm; |
|||
import std.stdio, std.array, std.range, std.algorithm; |
|||
⚫ | |||
enum n = 12; |
enum n = 12; |
||
writefln(" %(%4d%)\n%s", iota(1, |
writefln(" %(%4d%)\n%s", iota(1,n+1), "-".replicate(4 * (n+1))); |
||
foreach (immutable y; 1 .. n + 1) |
foreach (immutable y; 1 .. n + 1) |
||
writefln("%4d" ~ " ". |
writefln("%4d" ~ " ".replicate(4 * (y - 1)) ~ "%(%4d%)", y, |
||
iota(y, n + 1).map!(x => x * y)); |
iota(y, n + 1).map!(x => x * y)); |
||
}</lang> |
}</lang> |