function unitMatrix(n) { return map(range(n), function(k1, v1) { return map(range(n), function(k2, v2) { return v2 == v1 ? 1 : 0; }); }); }