rpn_calculator v2

This commit is contained in:
Danil Negrienko 2024-03-07 02:05:21 -05:00
parent d1b894006c
commit 7ae168f5ea
1 changed files with 6 additions and 10 deletions

View File

@ -4,18 +4,14 @@ defmodule RPNCalculator do
end end
def calculate(stack, operation) do def calculate(stack, operation) do
try do
{:ok, operation.(stack)} {:ok, operation.(stack)}
rescue rescue
_e -> :error _e -> :error
end end
end
def calculate_verbose(stack, operation) do def calculate_verbose(stack, operation) do
try do
{:ok, operation.(stack)} {:ok, operation.(stack)}
rescue rescue
e -> {:error, e.message} e -> {:error, e.message}
end end
end
end end