Jump to content

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

(New Task realızed ın F#)
 
Line 52:
Finally create your own 51 digit factorial base number and produce the corresponding permutation of the above shoe
=={{header|F_Sharp|F#}}==
===;The Functıons===:
<lang fsharp>
// Factorial base numbers indexing permutations of a collection
Line 65:
seq{yield n; while [1..α]|>List.exists(fun g->fN (α-g)) do yield n}
</lang>
 
===;Re-create the table===:
<lang fsharp>
lN 3 |> Seq.iter (fun n->printfn "%A -> %A" n (lN2p n [|0;1;2;3|]));;
Line 96 ⟶ 97:
[|3; 2; 1|] -> [|3; 2; 1; 0|]
</pre>
 
===;Shuffles===:
<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♣";|]
Line 113 ⟶ 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â™
</pre>
 
===;Comparıson wıth [[http://www.rosettacode.org/wiki/Permutations#F.23 Permutations(F#)]]===:
<lang fsharp>
let g=[|0..10|]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.