Created
September 4, 2022 22:26
-
-
Save rugyoga/7e06986ea10db0fb7a82f6815780d2bf to your computer and use it in GitHub Desktop.
Take the delta of two simple velues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spec delta_simple(path(), term(), term()) :: [delta()] | |
defp delta_simple(_path, a, b) when a == b, do: [] | |
defp delta_simple(path, a, b) do | |
cond do | |
empty?(a) -> [{path, {:add, b}}] | |
empty?(b) -> [{path, {:delete, a}}] | |
true -> [{path, {:update, a, b}}] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment