Ad
  • Custom User Avatar

    Thank you for your suggestions.
    I absolutely missed that I can ignore the x in the last pattern.

    I will check how the order of the pattern matching influences performance in bigger functions or even applications. Thank you for the hint, I never thought of it so far.

  • Custom User Avatar

    This is a really good solution but two suggestions.

    You can speed the execution up by performing the error check as the final pattner. This prevents you from checking if the list is empty every itteration. This is a small issue in this example but is still good practice.

    In your last pattern, you should not be assigning x to a variable. Instead use _ to avoid an unnecessary assignment. Again, this is pretty minor in this example but useful as your code grows.