Skip to content

Improvement #5

@tehrun

Description

@tehrun

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions