This repository has been archived on 2023-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
iaj/TP1/Prolog/AidesCPP/4.cpp

23 lines
435 B
C++
Raw Permalink Normal View History

2023-02-01 10:10:53 +01:00
#include <SWI-cpp.h>
2023-02-01 10:19:02 +01:00
#include <cstdio>
2023-02-01 10:10:53 +01:00
// swipl-ld -ld g++ -goal true 4.cpp empty.pl
2023-02-01 10:19:02 +01:00
int main(int _ac, char **_av) {
2023-02-01 10:10:53 +01:00
printf("using fac.pl to compute 10!\n");
PL_initialise(_ac, _av);
PlTermv pl_args(1);
pl_args[0] = "fac.pl";
PlCall("consult", pl_args);
PlTermv pl_args2(2);
pl_args2[0] = 10;
PlQuery q0("fac", pl_args2);
2023-02-01 10:19:02 +01:00
while (q0.next_solution()) {
2023-02-01 10:10:53 +01:00
printf("---> %d\n", (int)pl_args2[1]);
}
return 0;
}