Wednesday, March 26, 2008

Rotate a matrix 90 degrees clockwise

R:

##Rotate a square matrix 90 degrees clockwise.
rot90 <- function(a) {
n <- dim(a)[1]
stopifnot(n==dim(a)[2])
t(a[n:1, ])
}

JavaScript:
Fill in a default value for every blank text field

Hello.

Matlab: Write numbers to a file:
f = fopen('test.txt', 'w');
fprintf(f, '%g\n', 1:50);
fclose(f);
(I'm sure there's a better way to do this.)

No comments: