Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created January 22, 2014 17:59
Show Gist options
  • Save rubysolo/8563844 to your computer and use it in GitHub Desktop.
Save rubysolo/8563844 to your computer and use it in GitHub Desktop.
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