Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let tails xs = Seq.unfold (fun es -> match es with [] -> None | _::er -> Some(es,er)) xs
- let rec combinations n xs =
- match n with
- | 0 -> Seq.singleton []
- | _ -> seq {for (y :: yr) in tails xs do
- yield! seq {for rest in combinations (n-1) yr do yield y :: rest}}
- [<EntryPoint>]
- let main args =
- [0..20]
- |> combinations 8
- |> Seq.toList
- |> printf "%A"
- 0
Add Comment
Please, Sign In to add comment