> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/m/mosaic_matrix.md).

# Mosaic matrix

```ruby
func mosaic_matrix(n) {
    n.of {|k|
        var(a,b) = (k.is_even ? (1,0) : (0,1))
        n.of {|j| j.is_even ? a : b }
    }
}
 
mosaic_matrix(5).each { .join(' ').say }; say ''
mosaic_matrix(6).each { .join(' ').say }
```

#### Output:

```
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

1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
```
