I am having an issue where I don’t know how to pass 2 lists from 2 different functions(fun1 and fun2) to one function(fun3) in a way where it uses both of them at the same time. I think the issue is the pattern matching, I don’t know how to format the individual lists to where fun3 can accept them at the same time. I am trying to stick to best practices using more smaller functions but do I need to just combine these functions so I can send them at the same time? Yes, I am a noobie so be kind oh elixir gods and goddesses.
Fun1
def videoFilePurifier(videoList), do: doVideoFilePurifier(videoList, [])
defp doVideoFilePurifier([], vFlaggedList) do
flaggedListFormatter(_, vFlaggedList)
end
defp doVideoFilePurifier([head | tail], vFlaggedList) do
if String.contains?(head, @extensionList) do
doVideoFilePurifier(tail, vFlaggedList)
else
vFlaggedList = List.insert_at(vFlaggedList, 0, head)
doVideoFilePurifier(tail, vFlaggedList)
end
end
Fun2
def nonVideoFilePurifier(nonVideoList), do: doNonVideoFilePurifier(nonVideoList, [])
defp doNonVideoFilePurifier([], nvFlaggedList) do
flaggedListFormatter(nvFlaggedList, _)
end
defp doNonVideoFilePurifier([head | tail], nvFlaggedList) do
if String.contains?(head, @extensionList) do
nvFlaggedList = List.insert_at(nvFlaggedList, 0, head)
doNonVideoFilePurifier(tail, nvFlaggedList)
else
doNonVideoFilePurifier(tail, nvFlaggedList)
end
end
Fun3
def flaggedListFormatter(nvFlaggedList, vFlaggedList) do
flaggedList = nvFlaggedList ++ vFlaggedList
doFlaggedListFormattter(flaggedList, %{})
end
defp doFlaggedListFormatter([], flaggedMap), do: IO.puts(flaggedMap)
defp doFlaggedListFormatter([head | tail], flaggedMap) do
fileName = Path.basename(head)
Map.put(flaggedMap, fileName, head)
doFlaggedListFormatter(tail, flaggedMap)
end