Hello! Thanks for all you do within the coding community.
I recently completed the High School Sweethearts exercise for Elixir within Exercism. I got the following feedback from the Elixir Analyzer:
Reusing an already written function can help when writing maintainable code. Reuse existing functions:
initial/1 can reuse first_letter/1initials/1 can reuse initial/1pair/2 can reuse initials/1
However, my code does reuse these functions. It just doesn't seem to be picked up since they're interpolated into a string. This may be something worth improving, if possible! My code below:
defmodule HighSchoolSweetheart do
def first_letter(name) do
String.trim(name) |> String.first()
end
def initial(name) do
"#{String.upcase(first_letter(name))}."
end
def initials(full_name) do
initials = String.split(full_name)
"#{initial(List.first(initials))} #{initial(List.last(initials))}"
end
def pair(full_name1, full_name2) do
first_initials = String.split(full_name1)
second_initials = String.split(full_name2)
"""
****** ******
** ** ** **
** ** ** **
** * **
** **
** #{initial(List.first(first_initials))} #{initial(List.last(first_initials))} + #{initial(List.first(second_initials))} #{initial(List.last(second_initials))} **
** **
** **
** **
** **
** **
** **
***
*
"""
end
end
Hello! Thanks for all you do within the coding community.
I recently completed the High School Sweethearts exercise for Elixir within Exercism. I got the following feedback from the Elixir Analyzer:
However, my code does reuse these functions. It just doesn't seem to be picked up since they're interpolated into a string. This may be something worth improving, if possible! My code below: