Subject: Re: Why learn Lisp From: Erik Naggum <firstname.lastname@example.org> Date: 28 Aug 2002 01:49:03 +0000 Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Thomas Stegen CES2000 | One "problem" is that recursion is often used and I do not have that much | training in reading recursive functions. But my guess is that this is a | trivial problem which will disappear with time :) Heh. Probably not. Recursion can be extremely hard to understand if you look too closely at it. E.g., the simple factorial function is hard to read if you try to think about what actually happens to 10! and you try to work out the recursive calls in your head. What you need to do with recursive functions is figure out the problem as composed of sub-problems that are just like itself. For instance, an iterative tree traversal function will do a lot of work to remember past nodes, while a recursive version can work on a single node at a time and completely hide the fact that the call stack holds all the information that the iterative version would have to allocate explicit memory to hold. So-called tail-recursive problems are only simple decompositions into itself without any new information in each step and it makes little sense to use this idiom even when you want to train yourself to think recursively, because the whole point with recursive functions is that the call stack contains useful information and tail-recursive functions only use the function call paradigm to express iteration. -- Erik Naggum, Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.