Møøse

Møre Møøse ...

package BinaryTree;
use Moose;

has 'node' => (is => 'rw', isa => 'Any');

has 'parent' => (
    is        => 'rw',
    isa       => 'BinaryTree',        
    predicate => 'has_parent',
    weak_ref  => 1,
);

has 'left' => (
    is        => 'rw',        
    isa       => 'BinaryTree',                
    predicate => 'has_left',  
    lazy      => 1,
    default   => sub { BinaryTree->new(parent => $_[0]) },       
);

has 'right' => (
    is        => 'rw',        
    isa       => 'BinaryTree',                
    predicate => 'has_right',   
    lazy      => 1,       
    default   => sub { BinaryTree->new(parent => $_[0]) },       
);
Copyright © 2006 Stevan Little