Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.alt.net!news.kjsl.com!usenet.stanford.edu!newsfeed.news.ucla.edu!news.usc.edu!news.isi.edu!usenet From: tar@sevak.isi.edu (Thomas A. Russ) Newsgroups: comp.lang.python,comp.lang.lisp Subject: Re: English Idiom in Unix: Directory Recursively Date: 19 May 2011 16:17:53 -0700 Organization: USC Information Sciences Institute Lines: 34 Sender: tar@blackcat.isi.edu Message-ID: References: <87aaekoab7.fsf@kuiper.lan.informatimago.com> <8762p7omzu.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: blackcat.isi.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5797 comp.lang.lisp:3560 "Pascal J. Bourguignon" writes: > tar@sevak.isi.edu (Thomas A. Russ) writes: > > > > This will only work if there is a backpointer to the parent. > > No, you don't need backpointers; some cases have been mentionned in the > other answer, but in general: > > (defun parent (tree node) > (if (member node (children tree)) > tree > (some (lambda (child) (parent child node)) (children tree)))) > > Yes, the question wasn't about time complexity. :-p Um, this is a recursive function. Inside PARENT, there is another call to PARENT. -- Thomas A. Russ, USC/Information Sciences Institute