AI-Prolog
view release on metacpan or search on metacpan
lib/AI/Prolog/Term/Cut.pm view on Meta::CPAN
$REVISION = '$Id: Cut.pm,v 1.2 2005/02/20 18:27:55 ovid Exp $';
$VERSION = '0.1';
@ISA = 'AI::Prolog::Term';
use strict;
use warnings;
use aliased 'AI::Prolog::Term';
sub new {
my ($proto, $stack_top) = @_;
my $self = $proto->SUPER::new('!',0);
$self->{varid} = $stack_top;
return $self;
}
sub to_string {
my $self = shift;
return "Cut->$self->{varid}";
}
sub dup { # XXX recast as Term?
lib/AI/Prolog/Term/Number.pm view on Meta::CPAN
$VERSION = '0.1';
@ISA = 'AI::Prolog::Term';
use strict;
use warnings;
use Scalar::Util qw/looks_like_number/;
use aliased 'AI::Prolog::Term';
sub new {
my ($proto, $number) = @_;
my $self = $proto->SUPER::new($number, 0);
$self->{varid} = defined $number && looks_like_number($number)
? $number
: 0;
return $self;
}
sub value { shift->{varid} }
sub dup { # should this be recast as the parent?
my $self = shift;
lib/AI/Prolog/TermList/Clause.pm view on Meta::CPAN
$VERSION = '0.1';
use strict;
use warnings;
use base 'AI::Prolog::TermList';
sub new {
# Term TermList
my $class = shift;
return $class->SUPER::new(@_);
}
sub to_string {
my $self = shift;
my ( $term, $next ) = ( $self->term, $self->next );
foreach ( $term, $next ) {
$_ = $_ ? $_->to_string : "null";
}
return sprintf "%s :- %s" => $term, $next;
}
lib/AI/Prolog/TermList/Primitive.pm view on Meta::CPAN
package AI::Prolog::TermList::Primitive;
$REVISION = '$Id: Primitive.pm,v 1.2 2005/02/20 18:27:55 ovid Exp $';
$VERSION = '0.1';
@ISA = 'AI::Prolog::TermList';
use strict;
use warnings;
use Scalar::Util qw/looks_like_number/;
sub new {
my ($class, $number) = @_;
my $self = $class->SUPER::new; # correct?
$self->{ID} = looks_like_number($number) ? $number : 0;
return $self;
}
sub ID { shift->{ID} }
sub to_string { " <".shift->{ID}."> " }
1;
lib/AI/Prolog/TermList/Step.pm view on Meta::CPAN
$REVISION = '$Id: Step.pm,v 1.2 2005/02/20 18:27:55 ovid Exp $';
$VERSION = '0.1';
@ISA = 'AI::Prolog::TermList';
use strict;
use warnings;
use aliased 'AI::Prolog::Term';
sub new {
my ($class, $termlist) = @_;
my $self = $class->SUPER::new;
$self->{next} = $termlist->next;
$termlist->{next} = $self;
$self->{term} = Term->new('STEP',0);
return $self;
}
1;
__END__
( run in 1.040 second using v1.01-cache-2.11-cpan-49f99fa48dc )