Construct Reduce Convert
Section
input = "42"
input |> to_string()
defmodule CRC do
def new(input) do
String.to_integer(input)
end
def add(acc, item) do
acc + item
end
def show(acc) do
"The ants arrrrr is #{acc}"
end
end
input
|> CRC.new()
|> CRC.add(1)
|> CRC.add(1)
|> CRC.add(-1)
|> CRC.show()
list = [1, 1, -1]
reducer = &CRC.add/2
Enum.reduce(list, CRC.new(input), reducer)
|> CRC.show()