Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.113 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; 'compute': 0.09; 'pm,': 0.11; 'written': 0.12; 'binary': 0.14; 'wrote:': 0.14; 'definition,': 0.16; 'fruit': 0.16; 'hypothetical': 0.16; 'question?': 0.16; 'ways:': 0.16; 'algorithm': 0.16; 'structures': 0.16; 'tree': 0.20; 'header:In-Reply-To:1': 0.22; 'lee': 0.22; 'right,': 0.22; 'right.': 0.22; 'itself,': 0.23; 'example': 0.24; 'function': 0.27; 'this.': 0.30; 'tree.': 0.31; 'zero.': 0.31; 'does': 0.31; 'child': 0.31; 'to:addr:python-list': 0.32; 'things': 0.33; 'there': 0.35; 'print': 0.35; 'header:User- Agent:1': 0.35; 'url:comp': 0.35; 'none': 0.36; 'data': 0.37; 'two': 0.37; 'but': 0.38; 'delete': 0.38; 'url:org': 0.38; 'so,': 0.38; 'science': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'how': 0.39; 'whatever': 0.39; 'happened': 0.40; 'might': 0.40; 'simple,': 0.60; 'learn': 0.60; '8bit%:21': 0.60; 'happen': 0.61; 'and,': 0.63; 'visit': 0.67; 'divided': 0.73; 'god': 0.77; 'node': 0.84; 'organ': 0.84; 'perform.': 0.84; 'visit,': 0.84; '000': 0.91; 'holes': 0.91; 'subject:English': 0.91 Date: Tue, 17 May 2011 21:16:46 -0400 From: "Steven W. Orr" Organization: SysLang, Inc. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: English Idiom in Unix: Directory Recursively References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305681447 news.xs4all.nl 49177 [::ffff:82.94.164.166]:54361 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5639 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