Factorial base numbers indexing permutations of a collection: Difference between revisions
Content added Content deleted
(New Task realızed ın F#) |
(→{{header|F_Sharp|F#}}: style) |
||
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: |
|||
<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: |
|||
<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: |
|||
<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#)]]: |
|||
<lang fsharp> |
<lang fsharp> |
||
let g=[|0..10|] |
let g=[|0..10|] |