Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: recursive creation of attached objects?

by roboticus (Canon)
on Sep 14, 2012 at 13:57 UTC ( #993728=note: print w/ replies, xml ) Need Help??


in reply to recursive creation of attached objects?

You might play with this a bit:

#!/usr/bin/perl use 5.14.0; use warnings; use autodie; use Data::Dumper; my $t = myTree::create_tree(5); print Dumper($t); package myTree; sub create_tree { my $depth = shift; my $object = { left =>$depth ? create_tree($depth-1) : undef, right=>$depth ? create_tree($depth-1) : undef }; return bless $object; }

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re: recursive creation of attached objects?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993728]
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: (7)
As of 2014-08-30 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls