On Wed, Oct 30, 2002 at 04:03:55PM +0000, Piers Cawley wrote: > Jonathan Scott Duff <[EMAIL PROTECTED]> writes: > > 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. > > Nah, it'll die when there isn't a path.
duh! Of course. I was too busy thinking about the recursion. > > Perhaps where you have "die" there should be something like > > $src.collapse or maybe just "return undef". > > Well, traditionally you have 'fail' there, wants to be some kind of > exception, but I'm not entirely sure of what the semantics should > be. In my very-non-exceptional programming, I'd want undef if there wasn't a path. So, I guess your code is just fine but needs a CATCH block in there. The superposition collapses when it finds a path or finds that there is no path, no backtracking would be required. -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]