Mosaic matrix: Difference between revisions
Content added Content deleted
(Created Nim solution.) |
imported>Maxima enthusiast No edit summary |
||
Line 897: | Line 897: | ||
1 0 1 0 1 |
1 0 1 0 1 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Maxima}}== |
|||
<syntaxhighlight lang="maxima"> |
|||
/* Function that returns a mosaic matrix */ |
|||
mosaic(n):=genmatrix(lambda([i,j],charfun(evenp(abs(i-j)))),n,n)$ |
|||
/* Examples */ |
|||
mosaic(3); |
|||
mosaic(4); |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
matrix( |
|||
[1, 0, 1], |
|||
[0, 1, 0], |
|||
[1, 0, 1] |
|||
) |
|||
matrix( |
|||
[1, 0, 1, 0], |
|||
[0, 1, 0, 1], |
|||
[1, 0, 1, 0], |
|||
[0, 1, 0, 1] |
|||
) |
|||
</pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |