Mosaic matrix: Difference between revisions
Content added Content deleted
(add →Pascal) |
|||
Line 653: | Line 653: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
See [[Matrix_with_two_diagonals#GUI.2Fonline|Matrix_with_two_diagonals#Phix]] and press 'M'. |
See [[Matrix_with_two_diagonals#GUI.2Fonline|Matrix_with_two_diagonals#Phix]] and press 'M'. |
||
=={{header|Picat}}== |
|||
===Imperative=== |
|||
<lang Picat>go => |
|||
N = 6, |
|||
A = new_array(N,N), |
|||
bind_vars(A,"."), |
|||
foreach(I in 1..N) |
|||
foreach(J in 1..N, I mod 2 == J mod 2) |
|||
A[I,J] := "1" |
|||
end, |
|||
println(A[I].to_list.join(" ")) |
|||
end.</lang> |
|||
{{out}} |
|||
<pre>1 . 1 . 1 . |
|||
. 1 . 1 . 1 |
|||
1 . 1 . 1 . |
|||
. 1 . 1 . 1 |
|||
1 . 1 . 1 . |
|||
. 1 . 1 . 1</pre> |
|||
===List comprehension=== |
|||
<lang Picat>main => |
|||
N=11, |
|||
[[((1+I^J)/\1).to_string:J in 1..N].join:I in 1..N].join("\n").println.</lang> |
|||
{{out}} |
|||
<pre>1 0 1 0 1 0 1 0 1 0 1 |
|||
0 1 0 1 0 1 0 1 0 1 0 |
|||
1 0 1 0 1 0 1 0 1 0 1 |
|||
0 1 0 1 0 1 0 1 0 1 0 |
|||
1 0 1 0 1 0 1 0 1 0 1 |
|||
0 1 0 1 0 1 0 1 0 1 0 |
|||
1 0 1 0 1 0 1 0 1 0 1 |
|||
0 1 0 1 0 1 0 1 0 1 0 |
|||
1 0 1 0 1 0 1 0 1 0 1 |
|||
0 1 0 1 0 1 0 1 0 1 0 |
|||
1 0 1 0 1 0 1 0 1 0 1</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |