Mosaic matrix: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Added Arturo implementation) |
(add →Pascal) |
||
Line 590: | Line 590: | ||
1 0 1 0 1 |
1 0 1 0 1 |
||
</lang> |
</lang> |
||
=={{header|Pascal}}== |
|||
<lang pascal>program mosaicMatrix(output); |
|||
const |
|||
filledCell = '1'; |
|||
emptyCell = '⋅'; |
|||
procedure printMosaicMatrix(dimension: integer); |
|||
var |
|||
line: integer; |
|||
begin |
|||
{ NB: In Pascal, `for`-loop-limits are evaluated exactly once. } |
|||
for line := 1 to dimension do |
|||
begin |
|||
for dimension := 1 to dimension do |
|||
begin |
|||
{ `ord(odd(line))` is either zero or one. } |
|||
if odd(dimension + ord(odd(line))) then |
|||
begin |
|||
{ `write(emptyCell)` is shorthand for `write(output, emptyCell)`. } |
|||
write(emptyCell) |
|||
end |
|||
else |
|||
begin |
|||
write(filledCell) |
|||
end |
|||
end; |
|||
writeLn |
|||
end |
|||
end; |
|||
begin |
|||
printMosaicMatrix(9) |
|||
end.</lang> |
|||
{{out}} |
|||
1⋅1⋅1⋅1⋅1 |
|||
⋅1⋅1⋅1⋅1⋅ |
|||
1⋅1⋅1⋅1⋅1 |
|||
⋅1⋅1⋅1⋅1⋅ |
|||
1⋅1⋅1⋅1⋅1 |
|||
⋅1⋅1⋅1⋅1⋅ |
|||
1⋅1⋅1⋅1⋅1 |
|||
⋅1⋅1⋅1⋅1⋅ |
|||
1⋅1⋅1⋅1⋅1 |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |