IsValid checks if the input matrix has consistent row lengths.
(elements [][]T)
| 4 | |
| 5 | // IsValid checks if the input matrix has consistent row lengths. |
| 6 | func IsValid[T constraints.Integer](elements [][]T) bool { |
| 7 | if len(elements) == 0 { |
| 8 | return true |
| 9 | } |
| 10 | columns := len(elements[0]) |
| 11 | for _, row := range elements { |
| 12 | if len(row) != columns { |
| 13 | return false |
| 14 | } |
| 15 | } |
| 16 | return true |
| 17 | } |
no outgoing calls