Last active
September 25, 2016 23:14
-
-
Save jwosty/f6f5d8ef0b1509f7fbd87aacbc08cb7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec genPairs list = | |
match list with | |
| [] -> [] | |
| x::ys -> [for y in ys -> x, y] @ genPairs ys | |
let items = ["joe"; "jim"; "jack"; "jud"] | |
let r = new System.Random() | |
let shuffle cards = cards |> List.map (fun card -> r.Next(),card) |> List.sort |> List.map snd | |
items |> shuffle | |
let rec dealPairs pairs = | |
match pairs with | |
| [] -> [] | |
| (x1,x2)::rest -> | |
let withoutx1x2 = | |
List.filter (fun (rest1, rest2) -> | |
rest1 <> x1 && rest1 <> x2 && rest2 <> x1 && rest2 <> x2) | |
rest | |
(x1,x2) :: dealPairs withoutx1x2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment