AI-Prolog
view release on metacpan or search on metacpan
lib/AI/Prolog/TermList.pm view on Meta::CPAN
return $self;
}
return $self->{next};
}
sub next_clause {
my $self = shift;
if (@_) {
# XXX debug
my $next_clause = shift;
no warnings 'uninitialized';
if ( $next_clause eq $self ) {
confess("Trying to assign a termlist as its own successor");
}
$self->{next_clause} = $next_clause;
return $self;
}
return $self->{next_clause};
}
sub to_string {
my $self = shift;
my $indent = "\n\t";
my $to_string = $indent . $self->term->to_string;
#my $to_string = "[" . $self->term->to_string;
my $tl = $self->next;
while ($tl) {
$to_string .= ",$indent" . $tl->term->to_string;
$tl = $tl->next;
}
return $to_string;
}
sub resolve { # a.k.a. lookup_in
my ( $self, $kb ) = @_;
my $predicate = $self->{term}->predicate;
$self->next_clause( $kb->get($predicate) );
}
1;
__END__
=head1 NAME
AI::Prolog::TermList - Create lists of Prolog Terms.
=head1 SYNOPSIS
No user serviceable parts inside. You should never be seeing this.
=head1 DESCRIPTION
See L<AI::Prolog|AI::Prolog> for more information. If you must know more,
there are plenty of comments sprinkled through the code.
=head1 SEE ALSO
W-Prolog: L<http://goanna.cs.rmit.edu.au/~winikoff/wp/>
Michael BartE<225>k's online guide to programming Prolog:
L<http://kti.ms.mff.cuni.cz/~bartak/prolog/index.html>
=head1 AUTHOR
Curtis "Ovid" Poe, E<lt>moc tod oohay ta eop_divo_sitrucE<gt>
Reverse the name to email me.
This work is based on W-Prolog, L<http://goanna.cs.rmit.edu.au/~winikoff/wp/>,
by Dr. Michael Winikoff. Many thanks to Dr. Winikoff for granting me
permission to port this.
=head1 COPYRIGHT AND LICENSE
Copyright 2005 by Curtis "Ovid" Poe
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
( run in 0.449 second using v1.01-cache-2.11-cpan-e1769b4cff6 )