Firstly, I'd like to thank you for the amazing tutorial.
For the partial occurrence, I'd format both value and head to downcase and then return head inside the list to keep the original value:
def partial_occurrence([], _value), do: []
def partial_occurrence([head | tail], value) do
if String.contains?(format_string(head), format_string(value)) do
[head | partial_occurrence(tail, value)]
else
partial_occurrence(tail, value)
end
end
defp format_string(value) do
value
|> String.downcase()
end
Firstly, I'd like to thank you for the amazing tutorial.
For the partial occurrence, I'd format both value and head to
downcaseand then return head inside the list to keep the original value: