This commit is contained in:
bluepython508
2023-12-02 18:13:05 +00:00
parent 70cf651767
commit c6c501af2a
5 changed files with 70 additions and 0 deletions

View File

@@ -1,4 +1,15 @@
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