rpn_calculator v2
This commit is contained in:
parent
d1b894006c
commit
7ae168f5ea
|
@ -4,18 +4,14 @@ defmodule RPNCalculator do
|
|||
end
|
||||
|
||||
def calculate(stack, operation) do
|
||||
try do
|
||||
{:ok, operation.(stack)}
|
||||
rescue
|
||||
_e -> :error
|
||||
end
|
||||
{:ok, operation.(stack)}
|
||||
rescue
|
||||
_e -> :error
|
||||
end
|
||||
|
||||
def calculate_verbose(stack, operation) do
|
||||
try do
|
||||
{:ok, operation.(stack)}
|
||||
rescue
|
||||
e -> {:error, e.message}
|
||||
end
|
||||
{:ok, operation.(stack)}
|
||||
rescue
|
||||
e -> {:error, e.message}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue