Factorial base numbers indexing permutations of a collection: Difference between revisions

Content added Content deleted
(New Task realızed ın F#)
 
Line 52: Line 52:
Finally create your own 51 digit factorial base number and produce the corresponding permutation of the above shoe
Finally create your own 51 digit factorial base number and produce the corresponding permutation of the above shoe
=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
===The Functıons===
;The Functıons:
<lang fsharp>
<lang fsharp>
// Factorial base numbers indexing permutations of a collection
// Factorial base numbers indexing permutations of a collection
Line 65: Line 65:
seq{yield n; while [1..α]|>List.exists(fun g->fN (α-g)) do yield n}
seq{yield n; while [1..α]|>List.exists(fun g->fN (α-g)) do yield n}
</lang>
</lang>

===Re-create the table===
;Re-create the table:
<lang fsharp>
<lang fsharp>
lN 3 |> Seq.iter (fun n->printfn "%A -> %A" n (lN2p n [|0;1;2;3|]));;
lN 3 |> Seq.iter (fun n->printfn "%A -> %A" n (lN2p n [|0;1;2;3|]));;
Line 96: Line 97:
[|3; 2; 1|] -> [|3; 2; 1; 0|]
[|3; 2; 1|] -> [|3; 2; 1; 0|]
</pre>
</pre>

===Shuffles===
;Shuffles:
<lang fsharp>
<lang fsharp>
let shoe=[|"A♠";"K♠";"Q♠";"J♠";"10♠";"9♠";"8♠";"7♠";"6♠";"5♠";"4♠";"3♠";"2♠";"A♥";"K♥";"Q♥";"J♥";"10♥";"9♥";"8♥";"7♥";"6♥";"5♥";"4♥";"3♥";"2♥";"A♦";"K♦";"Q♦";"J♦";"10♦";"9♦";"8♦";"7♦";"6♦";"5♦";"4♦";"3♦";"2♦";"A♣";"K♣";"Q♣";"J♣";"10♣";"9♣";"8♣";"7♣";"6♣";"5♣";"4♣";"3♣";"2♣";|]
let shoe=[|"A♠";"K♠";"Q♠";"J♠";"10♠";"9♠";"8♠";"7♠";"6♠";"5♠";"4♠";"3♠";"2♠";"A♥";"K♥";"Q♥";"J♥";"10♥";"9♥";"8♥";"7♥";"6♥";"5♥";"4♥";"3♥";"2♥";"A♦";"K♦";"Q♦";"J♦";"10♦";"9♦";"8♦";"7♦";"6♦";"5♦";"4♦";"3♦";"2♦";"A♣";"K♣";"Q♣";"J♣";"10♣";"9♣";"8♣";"7♣";"6♣";"5♣";"4♣";"3♣";"2♣";|]
Line 113: Line 115:
2♣ 5♣ J♥ 4♥ Jâ™ Aâ™ 5♥ A♣ 6♦ Qâ™ 9♣ 3♦ Q♥ J♣ 10♥ K♣ 10♣ 5♦ 7♥ 10♦ 3â™ 8♥ 10â™ 7â™ 6♥ 5â™ K♥ 4♦ A♥ 4♣ 2♥ 9♦ Q♣ 8♣ 7♦ 6♣ 3♥ 6â™ 7♣ 2♦ J♦ 9♥ A♦ Q♦ 8♦ 4â™ K♦ Kâ™ 3♣ 2â™ 8â™ 9â™
2♣ 5♣ J♥ 4♥ Jâ™ Aâ™ 5♥ A♣ 6♦ Qâ™ 9♣ 3♦ Q♥ J♣ 10♥ K♣ 10♣ 5♦ 7♥ 10♦ 3â™ 8♥ 10â™ 7â™ 6♥ 5â™ K♥ 4♦ A♥ 4♣ 2♥ 9♦ Q♣ 8♣ 7♦ 6♣ 3♥ 6â™ 7♣ 2♦ J♦ 9♥ A♦ Q♦ 8♦ 4â™ K♦ Kâ™ 3♣ 2â™ 8â™ 9â™
</pre>
</pre>

===Comparıson wıth [[http://www.rosettacode.org/wiki/Permutations#F.23 Permutations(F#)]]===
;Comparıson wıth [[http://www.rosettacode.org/wiki/Permutations#F.23 Permutations(F#)]]:
<lang fsharp>
<lang fsharp>
let g=[|0..10|]
let g=[|0..10|]