Created
May 16, 2019 05:38
-
-
Save rargulati/df0240c84efb6c73b482288120ca97ee to your computer and use it in GitHub Desktop.
This language is so much fun...
This file contains 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
iex(3)> deck = for rank <- [ "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" ], suit <- [ "♣", "♦", "♥", "♠" ], do: {rank, suit} | |
[ | |
{"2", "♣"}, | |
{"2", "♦"}, | |
{"2", "♥"}, | |
{"2", "♠"}, | |
{"3", "♣"}, | |
{"3", "♦"}, | |
{"3", "♥"}, | |
{"3", "♠"}, | |
{"4", "♣"}, | |
{"4", "♦"}, | |
{"4", "♥"}, | |
{"4", "♠"}, | |
{"5", "♣"}, | |
{"5", "♦"}, | |
{"5", "♥"}, | |
{"5", "♠"}, | |
{"6", "♣"}, | |
{"6", "♦"}, | |
{"6", "♥"}, | |
{"6", "♠"}, | |
{"7", "♣"}, | |
{"7", "♦"}, | |
{"7", "♥"}, | |
{"7", "♠"}, | |
{"8", "♣"}, | |
{"8", "♦"}, | |
{"8", "♥"}, | |
{"8", "♠"}, | |
{"9", "♣"}, | |
{"9", "♦"}, | |
{"9", "♥"}, | |
{"9", "♠"}, | |
{"10", "♣"}, | |
{"10", "♦"}, | |
{"10", "♥"}, | |
{"10", "♠"}, | |
{"J", "♣"}, | |
{"J", "♦"}, | |
{"J", "♥"}, | |
{"J", "♠"}, | |
{"Q", "♣"}, | |
{"Q", "♦"}, | |
{"Q", "♥"}, | |
{"Q", "♠"}, | |
{"K", "♣"}, | |
{"K", "♦"}, | |
{"K", "♥"}, | |
{"K", "♠"}, | |
{"A", ...}, | |
{...}, | |
... | |
] | |
iex(12)> deck |> Enum.shuffle |> Enum.chunk_every(13) | |
[ | |
[ | |
{"9", "♣"}, | |
{"10", "♠"}, | |
{"9", "♠"}, | |
{"6", "♥"}, | |
{"2", "♦"}, | |
{"6", "♣"}, | |
{"J", "♣"}, | |
{"A", "♠"}, | |
{"7", "♦"}, | |
{"8", "♥"}, | |
{"3", "♠"}, | |
{"J", "♥"}, | |
{"6", "♠"} | |
], | |
[ | |
{"4", "♦"}, | |
{"Q", "♥"}, | |
{"K", "♣"}, | |
{"2", "♥"}, | |
{"10", "♣"}, | |
{"4", "♥"}, | |
{"5", "♥"}, | |
{"2", "♠"}, | |
{"4", "♣"}, | |
{"10", "♦"}, | |
{"5", "♦"}, | |
{"7", "♠"}, | |
{"Q", "♦"} | |
], | |
[ | |
{"Q", "♣"}, | |
{"5", "♠"}, | |
{"A", "♣"}, | |
{"K", "♥"}, | |
{"3", "♣"}, | |
{"A", "♥"}, | |
{"A", "♦"}, | |
{"K", "♦"}, | |
{"8", "♣"}, | |
{"9", "♦"}, | |
{"Q", "♠"}, | |
{"9", "♥"}, | |
{"2", "♣"} | |
], | |
[ | |
{"J", "♠"}, | |
{"5", "♣"}, | |
{"7", "♣"}, | |
{"J", "♦"}, | |
{"4", "♠"}, | |
{"8", "♦"}, | |
{"K", "♠"}, | |
{"3", "♥"}, | |
{"8", "♠"}, | |
{"3", "♦"}, | |
{"10", "♥"}, | |
{"7", "♥"}, | |
{"6", "♦"} | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment