Lexicon v0.1.1 Lexicon

A lexicon (word list) implemented in Elixir.

Summary

Functions

Adds a word to the lexicon

Checks if prefix is in the given lexicon

Checks if word is in the given lexicon

Returns a new empty lexicon

Creates a lexicon from an enumerable collection of words

Functions

add(lexicon, word)

Adds a word to the lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
#Lexicon<size: 2>
iex> Lexicon.add(lexicon, "elephant")
#Lexicon<size: 3>
has_prefix?(lexicon, word)

Checks if prefix is in the given lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
iex> Lexicon.has_prefix?(lexicon, "ca")
true
iex> Lexicon.has_prefix?(lexicon, "cat")
true
iex> Lexicon.has_prefix?(lexicon, "ba")
false
has_word?(lexicon, word)

Checks if word is in the given lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
iex> Lexicon.has_word?(lexicon, "cat")
true
iex> Lexicon.has_word?(lexicon, "ca")
false
new()

Returns a new empty lexicon.

Examples

iex> Lexicon.new()
#Lexicon<size: 0>
new(enumerable)

Creates a lexicon from an enumerable collection of words.

Examples

iex> Lexicon.new([])
#Lexicon<size: 0>
iex> Lexicon.new(["cat", "dog"])
#Lexicon<size: 2>