Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re (tilly) 1: Recursive generation of a sorted list from a hash

by hawson (Monk)
on Mar 23, 2001 at 21:12 UTC ( #66672=note: print w/replies, xml ) Need Help??


in reply to Re (tilly) 1: Recursive generation of a sorted list from a hash
in thread Recursive generation of a sorted list from a hash

Thanks.

It doesn't handle circular references..in fact, I think that is why it fails at the moment. I'm going to add some logic in there to see if a node has already been processed, and post the changes.

  • Comment on Re: Re (tilly) 1: Recursive generation of a sorted list from a hash

Replies are listed 'Best First'.
Re: Re: Re (tilly) 1: Recursive generation of a sorted list from a hash
by hawson (Monk) on Mar 23, 2001 at 22:38 UTC
    A fairly simple change to my script fixed the problem. In each call to &Recurse I additionally pass a @stack list. This list contains all of the 'parent' nodes in the call tree. So when the function runs, it checks to see if the node is present in @stack, then I know there is circular reference.

    So, the inital invocation of &Recurse becomes: &Recurse($_,()), and subsequent calls (the truly recursive ones) turn into: &Recurse($node,@stack,$node).

    This works, although tilly has a much more compact solution. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://66672]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-01-30 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?