RosettaCodeData/Task/Identity-matrix/Sidef/identity-matrix.sidef

15 lines
230 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

func identity_matrix(n) {
n.of { |i|
n.of { |j|
i == j ? 1 : 0
}
}
}
for n (ARGV ? ARGV.map{.to_i} : [4, 5, 6]) {
say "\n#{n}:"
for row (identity_matrix(n)) {
say row.join(' ')
}
}