Skip to content

Instantly share code, notes, and snippets.

@paulohp
Created November 18, 2016 13:55
Show Gist options
  • Save paulohp/f6803bd8ec3df9ad0ad95cfdc2e7b31b to your computer and use it in GitHub Desktop.
Save paulohp/f6803bd8ec3df9ad0ad95cfdc2e7b31b to your computer and use it in GitHub Desktop.
defmodule Cards do
def create_deck do
values = ["Ace", "Two", "Three"]
suits = ["Spades", "Clubs", "Hearts", "Diamonds"]
for value <- values, suit <- suits do
"#{value} of #{suit}"
end
end
def shuffle(deck) do
Enum.shuffle(deck)
end
def contains?(deck, card) do
Enum.member?(deck, card)
end
def deal(deck, hand_size) do
Enum.split(deck, hand_size)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment