Closed chaychoong closed 1 year ago
Hi! Thanks for the feedback.
Using Enum.reverse
is never strictly necessary. You can always implement your own recursive function that reverses a list, which is exactly what the analyzer comment is trying to get you to do. For reference, this is the ideal solution to the exercise.
the alternative - doing result ++ [decode_nucleotide(value)] - seems to be a very popular community solution, but should be discouraged since the complexity of appending to the end of the list is O(n), n being the length of the list.
Yes, definitely, that should be discouraged. Could you give me 3-4 links to community solutions that use ++
that you found? I looked at the top 12 community solutions, and didn't find any, but to my shock found way too many that don't even use tail call recursion at all :( another potential challenge for the analyzer (I opened a separate issue for that https://github.com/exercism/elixir-analyzer/issues/371).
Closing this issue
A solution for the
decode
method:Here, a Enum.reverse is necessary, since the new values are accumulated in the reverse order. However, the following warning is shown:
This warning should be removed.
Going one step further, the alternative - doing
result ++ [decode_nucleotide(value)]
- seems to be a very popular community solution, but should be discouraged since the complexity of appending to the end of the list isO(n)
,n
being the length of the list.