Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Combinations/F-Sharp/combinations.fs
Normal file
22
Task/Combinations/F-Sharp/combinations.fs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
let choose m n =
|
||||
let rec fC prefix m from = seq {
|
||||
let rec loopFor f = seq {
|
||||
match f with
|
||||
| [] -> ()
|
||||
| x::xs ->
|
||||
yield (x, fC [] (m-1) xs)
|
||||
yield! loopFor xs
|
||||
}
|
||||
if m = 0 then yield prefix
|
||||
else
|
||||
for (i, s) in loopFor from do
|
||||
for x in s do
|
||||
yield prefix@[i]@x
|
||||
}
|
||||
fC [] m [0..(n-1)]
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
choose 3 5
|
||||
|> Seq.iter (printfn "%A")
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue