Four sides of square: Difference between revisions
Content added Content deleted
(→{{header|Python}}: Added a functionally composed version.) |
|||
Line 392: | Line 392: | ||
viewmat fsosq 20 |
viewmat fsosq 20 |
||
viewmat fsosq 5</lang> |
viewmat fsosq 5</lang> |
||
=={{header|jq}}== |
|||
{{works with|jq}} |
|||
'''Works with gojq, the Go implementation of jq''' |
|||
<lang jq>def square_perimeter_matrix: |
|||
[range(0; .) | 1] as $top |
|||
| [1, (range(0; .-2) | 0), 1] as $two |
|||
| [$top, (range(0; .-2)|$two), $top];</lang> |
|||
def display: |
|||
map(join(" ")) | join("\n"); |
|||
</lang> |
|||
'''Example''': |
|||
<lang jq>9|square_perimeter_matrix|display |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1 1 1 1 1 1 1 1 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 0 0 0 0 0 0 0 1 |
|||
1 1 1 1 1 1 1 1 1 |
|||
</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |