Factorial base numbers indexing permutations of a collection: Difference between revisions
Factorial base numbers indexing permutations of a collection (view source)
Revision as of 11:49, 31 May 2019
, 5 years ago→{{header|F_Sharp|F#}}: modified lN to take a start value
(→{{header|F_Sharp|F#}}: Undo some idiots edit which stops it compiling) |
(→{{header|F_Sharp|F#}}: modified lN to take a start value) |
||
Line 66:
let rec fN i g e l=match l-i with 0->Ω.[i]<-e |_->Ω.[l]<-Ω.[l-1]; fN i g e (l-1)// rotate right
[0..((Array.length Ω)-2)]|>List.iter(fun n->let i=c.[n] in if i>0 then fN n (i+n) Ω.[i+n] (i+n)); Ω
let lN
let
let fN g=if n.[g]=Ω-g then n.[g]<-0; false else n.[g]<-n.[g]+1; true
seq{yield n; while [1..Ω]|>List.exists(fun g->fN (Ω-g)) do yield n}
Line 74:
;Re-create the table:
<lang fsharp>
lN
</lang>
{{out}}
|