Initial upload
This commit is contained in:
21
elixir/resistor-color/lib/resistor_color.ex
Normal file
21
elixir/resistor-color/lib/resistor_color.ex
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule ResistorColor do
|
||||
@resistors %{
|
||||
black: 0,
|
||||
brown: 1,
|
||||
red: 2,
|
||||
orange: 3,
|
||||
yellow: 4,
|
||||
green: 5,
|
||||
blue: 6,
|
||||
violet: 7,
|
||||
grey: 8,
|
||||
white: 9
|
||||
}
|
||||
@doc """
|
||||
Return the value of a color band
|
||||
"""
|
||||
@spec code(atom) :: integer()
|
||||
def code(color) when is_map_key(@resistors, color) do
|
||||
@resistors[color]
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user