allsums(magic(7))
allsums(magic(7),FUN=max)
allsums(magic(7),FUN=function(x){x[1:2]})
# shows how the minor diagonals are ordered: first [1,n] to [n,1] then
# [1,n+1] to [n,2] etc.
allsums(magic.prime(7),sort)
# beware! compare apply(magic(7),1,sort) with apply(magic(7),2,sort)
Run the code above in your browser using DataLab