basketball-website
This commit is contained in:
15
elixir/basketball-website/lib/basketball_website.ex
Normal file
15
elixir/basketball-website/lib/basketball_website.ex
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule BasketballWebsite do
|
||||
def extract_from_path(data, path) do
|
||||
path
|
||||
|> String.split(".")
|
||||
|> get_path(data)
|
||||
end
|
||||
|
||||
defp get_path(_list, nil), do: nil
|
||||
defp get_path([], data), do: data
|
||||
defp get_path([head | tail], data), do: get_path(tail, data[head])
|
||||
|
||||
def get_in_path(data, path) do
|
||||
get_in(data, String.split(path, "."))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user