On 5/17/2011 6:26 PM, Xah Lee wrote:
might be of interest.

〈English Idiom in Unix: Directory Recursively〉
http://xahlee.org/comp/idiom_directory_recursively.html

The answer is from compute science 101. From any standard data structures course, you learn the algorithm for how to walk a tree. To make it simple, the example is to use a binary tree which means that any non-leaf node of a tree may only have two child nodes, which are designated as Left and Right. There are only three things that are possible: Visit, Go Left, or Go Right. This means that a tree traversal program can only be written three ways:
A PreOrder Traversal will Visit, Go Left, Go Right.
An InOrder Traversal will Go Left, Visit, Go Right.
A PostOrder Traversal will Go Left, Go Right, Visit.

So, the Visit function is the function that does whatever you want to have happen at that node. Selection of whether you want to do things like copy, print or delete are designated by what kind of traversal you perform. And, since the Traversal function calls itself, it is, by definition, recursive.

QED.

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to