RosettaCodeData/Task/Identity-matrix/Groovy/identity-matrix-1.groovy
2023-07-01 13:44:08 -04:00

3 lines
105 B
Groovy

def makeIdentityMatrix = { n ->
(0..<n).collect { i -> (0..<n).collect { j -> (i == j) ? 1 : 0 } }
}