#!/usr/bin/ruby

#
## http://rosettacode.org/wiki/Identity_matrix
#

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