Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Elixir Notes

counter.livemd

Elixir Notes

CRC Counter

defmodule Counter do
  def new(string) do
    String.to_integer(string)
  end

  def add(counter, value \\ 1) do
    counter + value
  end

  def show(counter) do
    "The ans-ARRRR is #{counter}"
  end
end
input = "42"

input 
|> Counter.new() 
|> Counter.add(1) 
|> Counter.add(1) 
|> Counter.add(-1) 
|> Counter.show()