exercism/elixir/pangram/lib/pangram.ex

27 lines
519 B
Elixir
Raw Normal View History

2024-06-27 07:45:38 +00:00
defmodule Pangram do
@doc """
Determines if a word or sentence is a pangram.
A pangram is a sentence using every letter of the alphabet at least once.
Returns a boolean.
## Examples
iex> Pangram.pangram?("the quick brown fox jumps over the lazy dog")
true
"""
@alphabet Enum.to_list(?A..?Z)
@spec pangram?(String.t()) :: boolean
def pangram?(sentence) do
letters =
sentence
|> String.upcase()
|> String.to_charlist()
@alphabet -- letters == []
end
end