Created
January 22, 2014 17:59
-
-
Save rubysolo/8563844 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
defrecord Card, suit: nil, rank: nil | |
defmodule Cards do | |
def create do | |
lc suit inlist [:H, :D, :C, :S], | |
rank inlist [:A, 2, 3, 4, 5, 6, 7, 8, 9, 10, :J, :Q, :K] do | |
Card.new suit: suit, rank: rank, points: score(rank) | |
end | |
end | |
def score(rank) when is_number(rank), do: rank | |
def score(:A), do: 1 | |
def score(_), do: 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment