我有个问题。几个星期我都无法弄清楚这个问题。例如:
parent(john,paul).
parent(paul,tom).
parent(tom,mary).
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z),
ancestor(Z,Y).
查询是:
swipl -s /home/alikoyuncu/pl/ples.pl -g "ancestor(X,'tom')" -t halt.
输出 :
% library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,856 bytes
% /home/alikoyuncu/pl/ples.pl compiled 0.01 sec, 119,096 bytes
alikoyuncu@alikoyuncu-EasyNote-TM98:/var/www/nlp$
我应该怎么做才能获得变量 X ?
我从 php 调用。我的PHP代码:
<?php
try
{
$cmd ="swipl --quiet -s /home/alikoyuncu/pl/ples.pl -g \"forall(f(X,gel),writeln(X))\" -t halt.";
$cmd2="/var/www/nlp/betik.sh";
exec( $cmd, $output );
if($output==null)
{
echo "null";
}
else
{
foreach( $output as $tampon ) { echo "$tampon .nci satir <br>"; };
}
}
catch(Exception $ex)
{
echo "Error";
}
?>