Guest User

Untitled

a guest
Oct 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. let tails xs = Seq.unfold (fun es -> match es with [] -> None | _::er -> Some(es,er)) xs
  2.  
  3. let rec combinations n xs =
  4. match n with
  5. | 0 -> Seq.singleton []
  6. | _ -> seq {for (y :: yr) in tails xs do
  7. yield! seq {for rest in combinations (n-1) yr do yield y :: rest}}
  8.  
  9. [<EntryPoint>]
  10. let main args =
  11. [0..20]
  12. |> combinations 8
  13. |> Seq.toList
  14. |> printf "%A"
  15. 0
Add Comment
Please, Sign In to add comment