Files
aoc-2023/lib/common.ex
bluepython508 c6c501af2a Day 2
2023-12-02 18:13:05 +00:00

16 lines
340 B
Elixir

defmodule Aoc2023.Common do
def stringify(s) when is_binary(s) do s end
def stringify(n) when is_integer(n) do inspect(n) end
def stringify(nil), do: "nil"
def map_nth(tup, n, fun) do
put_elem(tup, n, fun.(elem(tup, n)))
end
defmacro pipe(expr) do
quote do
fn (val) -> val |> unquote(expr) end
end
end
end