[Tutor] recursivity and lists

Danny Yoo danny.yoo at gmail.com
Thu Mar 3 16:29:35 EST 2016


Some code comments:  The solution you have depends very much on mutation
and side effects: I recommend you try to stay as functional as you can in
this situation.

By mixing mutation into the solution, there are certain things that the
program is doing that isn't part of the traditional behavior of a merge
sort.

For example, it is actively mutating the input lists.  That's both
surprising and error prone.

Also, the purpose for the second internal calls to the merge sort in your
current solution have nothing to do with merging, but rather to pick which
nonempty list to return as the result.  A reader of the code who doesn't
look at this code *very* carefully would wonder why the function wasn't
infinite-looping.  It's a bit too clever for its own good.

Hope that makes sense!


More information about the Tutor mailing list