Subject: | Head/Tail results bug patch |
This is is fix for the infamous [HEAD|TAIL] result binding bug. Here is
a test program:
#!/usr/bin/perl
use strict;
use warnings;
use AI::Prolog;
use Data::Dumper qw(Dumper);
my $p = AI::Prolog->new(<<EOT);
foo(X,[1,2,3,4]).
EOT
$p->raw_results(0);
$p->query('foo(1,[X,Y|Z])');
while (my $r = $p->results) {
print Dumper $r;
}
Subject: | Term.pm.diff |
--- TermOld.pm 2007-05-04 20:02:48 -0700
+++ Term.pm 2011-01-19 17:01:41 -0800
@@ -425,7 +425,11 @@
my $term = $self->{args}[1];
while ( "cons" eq $term->getfunctor && 2 == $term->getarity ) {
- push @result => $term->getarg(0)->_to_data($parent);
+ if ( $term->{varname} ) {
+ push @result => $term->_to_data($parent);
+ } else {
+ push @result => $term->getarg(0)->_to_data($parent);
+ }
$term = $term->getarg(1);
}