English Idiom in Unix: Directory Recursively

Pascal J. Bourguignon pjb at informatimago.com
Thu May 19 20:38:39 EDT 2011


tar at sevak.isi.edu (Thomas A. Russ) writes:

> "Pascal J. Bourguignon" <pjb at informatimago.com> writes:
>
>> tar at 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.

Feel free to derecursive it.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.



More information about the Python-list mailing list