(* Lexdebruijn *) (* $Id: lexdebruijn.ml,v 1.1 2003/01/12 15:33:00 berke Exp $ *) (* Par Berke Durak *) let genlexdebr m = let n = 1 lsl m in let q = n - 1 in let a = String.make ((n + 7) lsr 3) '\000' in let rec loop x = let y = ((x lsl 1) lor 1) land q in if 0 = (Char.code a.[y lsr 3]) land (1 lsl (y land 7)) then begin print_char '1'; a.[y lsr 3] <- Char.chr ((Char.code a.[y lsr 3]) lor (1 lsl (y land 7))); loop y end else let y = y land (lnot 1) in if 0 = (Char.code a.[y lsr 3]) land (1 lsl (y land 7)) then begin a.[y lsr 3] <- Char.chr ((Char.code a.[y lsr 3]) lor (1 lsl (y land 7))); print_char '0'; loop y end else () in for i = 0 to m - 1 do print_char '0'; done; a.[0] <- '\001'; loop 0