Initial upload
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
|
||||
paths = String.split(path, ".")
|
||||
root = Enum.at(paths, 0)
|
||||
if length(paths) > 1 and data[root] do
|
||||
extract_from_path(data[root], Enum.slice(paths, 1..-1) |> Enum.join("."))
|
||||
else
|
||||
data[root]
|
||||
end
|
||||
end
|
||||
|
||||
def get_in_path(data, path) do
|
||||
Kernel.get_in(data, String.split(path, "."))
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user