dcmicoltacespedes
2020-6-14 13:16:48

Sorry @rokitna, I didn’t understand. What you mean is that the error is in the first condition where it only looks for the doubles? and that’s why that gap appears (first (rest list)) ??. The strange thing is that when I delete the first one, the program reads the rest (well, it’s an error, but I wanted to check if it was empty but it showed me the rest of the list) of the list but when I put the first it does not. thanks


rokitna
2020-6-14 13:45:00

The error is occurring at (first (rest list)) because (rest list) is the empty list, and you can’t get the first of an empty list. You need to check to make sure that the list is nonempty before calling first on it.

It looks like you might intend to perform that check in one of the previous branches, but none of your branches currently check for that.

  • You have a case that handles an empty list.

  • You have a case that handles lists where the first piece is a double.

You probably need another case that handles a list of length 1. That way, later branches can assume the length is greater than one, and they can access (first (rest list)) without an error.

The comment you’ve written on the double case suggests that you intended for it to check for lists of length 1, but that’s not what it’s doing.