J'ai un problème. Je ne peux pas comprendre ce problème pendant des semaines. Par exemple:Comment obtenir une variable dans Prolog?
parent(john,paul).
parent(paul,tom).
parent(tom,mary).
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z),
ancestor(Z,Y).
requête est:
swipl -s /home/alikoyuncu/pl/ples.pl -g "ancestor(X,'tom')" -t halt.
sortie:
% 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
[email protected]:/var/www/nlp$
Que dois-je faire pour obtenir la variable X?
et j'appelle de php. Mon code 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";
}
?>