// Set right-adjacent bits. Nigel Galloway: December 21st., 2021 let fN g l=let rec fG n g=[|match n,g with ('0'::t,0)->yield '0'; yield! fG t 0 |('0'::t,n)->yield '1'; yield! fG t (n-1) |(_::t,_) ->yield '1'; yield! fG t l |_ ->()|] fG (g|>List.ofSeq) 0|>System.String [("1000",2);("0100",2);("0010",2);("0001",2);("0000",2);("010000000000100000000010000000010000000100000010000010000100010010",0);("010000000000100000000010000000010000000100000010000010000100010010",1);("010000000000100000000010000000010000000100000010000010000100010010",2);("010000000000100000000010000000010000000100000010000010000100010010",3)]|>List.iter(fun(n,g)->printfn "%s\n%s" n (fN n g))