Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The above code is frowned upon because it is an encapsulation violation of rest, amounting to a checking of its type.    You may use this style for this assignment, but it is not recommended and you can expect to be marked down for it in the future.

The better solution is to delegate to rest and let it continue the process processing in a manner consistent with what it is. This     Remember that the last element of a list is defined by the fact that its rest is empty, or conversely, the parent of an empty list is the last element.  This thus requires a helper method:

...