View Source Hangman.Dictionary (Hangman Dictionary v0.1.29)
Dictionary for the Hangman Game. Returns a random word.
Based on the course Elixir for Programmers by Dave Thomas.
Link to this section Summary
Functions
Returns a random word from the dictionary agent.
Returns the number of words in the dictionary agent.
Link to this section Types
Specs
word() :: String.t()
A word with letters from a to z
Link to this section Functions
Specs
random_word() :: word()
Returns a random word from the dictionary agent.
Examples
iex> alias Hangman.Dictionary
iex> for _ <- 0..99, uniq: true do
iex> Dictionary.random_word() =~ ~r/^[a-z]+$/
iex> end
[true]
iex> alias Hangman.Dictionary.WordsAgent
iex> words = Agent.get(WordsAgent, & &1)
iex> Enum.all?(words, & &1 =~ ~r/^[a-z]+$/)
true
Specs
word_count() :: pos_integer()
Returns the number of words in the dictionary agent.
Examples
iex> alias Hangman.Dictionary
iex> Dictionary.word_count
9133