Versions Compared

Key

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

...

Think simple!
Follow these important rules whenever you write function on a list using structural recursion (note that the generative recursion that mergesort uses follows slightly different rules):

  • Write down and follow the list function template!
  • Think about what can be done with what your template says you have to work with, namely,
    Code Block
    (first aList)
    and the recursive result,
    Code Block
    (myFunction (rest aList))
    .
  • Never think in terms of more than one element of the list at a time (this is equivalent to the previous statement). This means do NOT think in terms of finding the length of the list or finding the middle of the list or anything of that nature! Think "first" and "rest", period.
  • Use a
    Code Block
    local
    definition to keep you from repeating the recursive call.