rpn_calculator

This commit is contained in:
2024-03-07 01:40:53 -05:00
parent 0c15aedc09
commit d1b894006c
11 changed files with 377 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
defmodule RPNCalculator do
def calculate!(stack, operation) do
operation.(stack)
end
def calculate(stack, operation) do
try do
{:ok, operation.(stack)}
rescue
_e -> :error
end
end
def calculate_verbose(stack, operation) do
try do
{:ok, operation.(stack)}
rescue
e -> {:error, e.message}
end
end
end