First commit

This commit is contained in:
Mariano Uvalle 2020-06-20 13:57:33 -05:00
commit 1dba0af064
36 changed files with 1065 additions and 0 deletions

16
chapter4/fraction.ex Normal file
View file

@ -0,0 +1,16 @@
defmodule Fraction do
defstruct a: nil, b: nil
def new(a, b), do: %Fraction{a: a, b: b}
def value(%Fraction{a: a, b: b}) do
a / b
end
def add(%Fraction{a: a1, b: b1}, %Fraction{a: a2, b: b2}) do
new(
a1 * b2 + a2 * b1,
b1 * b2
)
end
end