On Wed, Oct 30, 2002 at 02:25:02PM +0000, Piers Cawley wrote:
> Given an acyclic graph of nodes, where a node has a method C<kids>,
> returning a list of all the nodes it points to, is it the case that
> the following code:
> 
>   sub descent($src, $dst) {
>     when $src == $dst  { return $dst }
>     when !$src.kids    { die }
>     otherwise { 
>       return ( $src, descent(any($src.kids), $dst))
>     }
>   }
> 
> will return a list of nodes making up a path between the nodes $src
> and $dest? Or do I need to replace C<any> and C<die> with an
> appropriate implementation of C<choose> and C<fail>?
> 
> It'd be really cool if superpositions had this kind of backtracking
> behaviour, but I'm *so* not going to be surprised if it doesn't...

Hey, that's neat. Although it looks like it returns the $src when there
isn't a path. You probably want it to return undef or something.

Perhaps where you have "die" there should be something like
$src.collapse or maybe just "return undef".

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to