R/LyndonW.R

Defines functions LyndonW

Documented in LyndonW

LyndonW <- function(n=1,m=2,bOut=FALSE, fn=1){
  if (n < 1 || m< 1) stop("n and m must be positive integers");
  i<-0; oL<-list(); iL<-Necklaces(n,m,fn);
  for (u in iL[[2]]) { 
      if (length(cNecklaces(u))==n) {i<-i+1; oL[[i]]<-u};};
  oL<-lSort(oL);
  if (!bOut) return(oL);
  i<-1; for (w in oL) {cat("[",unlist(w),"]  (",i,")\n");i<-i+1};
}  

Try the Necklaces package in your browser

Any scripts or data that you put into this service are public.

Necklaces documentation built on Aug. 24, 2025, 9:07 a.m.