Learn R Programming

expperm (version 0.1.0)

gray: Gray code enumeration

Description

Computes the next binary string in a Gray code sequence using Knuth's Algorithm G.

Usage

gray(ind)

Arguments

ind

A binary string.

Value

The next binary string in the Gray code sequence.

Examples

Run this code
# NOT RUN {
n<-4
indi<-rep(0,n)
allinds<-c()
for(i in 1:(2^n)){
  allinds<-rbind(allinds,indi)
  indi<-gray(indi)
}
allinds
# }

Run the code above in your browser using DataLab