Created
February 16, 2016 05:10
-
-
Save certifiedwaif/d322b13d410b520395df to your computer and use it in GitHub Desktop.
I think the intent of this code is perfectly obvious</sarcasm>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
greycode <- function(p) | |
{ | |
A <- matrix(c(0,1),2,1) | |
if (p!=1) { | |
for (i in 2:p) { | |
P <- nrow(A) | |
inds <- rev(1:P) | |
A1 <- matrix(c(rep(0,P),rep(1,P)),2*P,1) | |
A2 <- rbind(A,matrix(A[inds,],nrow(A),ncol(A))) | |
A <- cbind(A1,A2) | |
} | |
} | |
return(A) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment