From 887b7098bc00aa6c7405c87d8ce89963de698f65 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 1 Feb 2023 10:19:02 +0100 Subject: [PATCH] format --- TP1/Prolog/AidesCPP/1.cpp | 7 ++++--- TP1/Prolog/AidesCPP/2-f.pl | 2 +- TP1/Prolog/AidesCPP/2.cpp | 8 ++++---- TP1/Prolog/AidesCPP/3-f.pl | 2 +- TP1/Prolog/AidesCPP/3.cpp | 9 +++++---- TP1/Prolog/AidesCPP/4.cpp | 6 +++--- TP1/Prolog/AidesCPP/fac.pl | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/TP1/Prolog/AidesCPP/1.cpp b/TP1/Prolog/AidesCPP/1.cpp index 6cf6a3a..6124791 100644 --- a/TP1/Prolog/AidesCPP/1.cpp +++ b/TP1/Prolog/AidesCPP/1.cpp @@ -1,5 +1,5 @@ -#include #include +#include // après avoir installé swi-prolog (et peut être aussi swi-prolog-devel) // pour pouvoir appeler Prolog à partir du C/C++ @@ -10,9 +10,10 @@ // pkg-config swipl --libs // et selon les paramètres précédents, pour compiler -// g++ 1.cpp -I /opt/local/lib/swipl/include -L/opt/local/lib/swipl/lib/arm64-darwin -lswipl +// g++ 1.cpp -I /opt/local/lib/swipl/include +// -L/opt/local/lib/swipl/lib/arm64-darwin -lswipl -int main(int _ac, char** _av) { +int main(int _ac, char **_av) { PL_initialise(_ac, _av); printf("ok\n"); return 0; diff --git a/TP1/Prolog/AidesCPP/2-f.pl b/TP1/Prolog/AidesCPP/2-f.pl index 9d6f9d1..e77ef09 100644 --- a/TP1/Prolog/AidesCPP/2-f.pl +++ b/TP1/Prolog/AidesCPP/2-f.pl @@ -1,3 +1,3 @@ f(1). f(2). -f(3). \ No newline at end of file +f(3). diff --git a/TP1/Prolog/AidesCPP/2.cpp b/TP1/Prolog/AidesCPP/2.cpp index 1cceca0..fb49da9 100644 --- a/TP1/Prolog/AidesCPP/2.cpp +++ b/TP1/Prolog/AidesCPP/2.cpp @@ -1,15 +1,15 @@ -#include #include +#include // swipl-ld -ld g++ -goal true 2.cpp 2-f.pl // attention, recompile nécessaire si 2-f.pl change -int main(int _ac, char** _av) { +int main(int _ac, char **_av) { PL_initialise(_ac, _av); - + PlTermv pl_args2(1); PlQuery q0("f", pl_args2); - while( q0.next_solution()) { + while (q0.next_solution()) { printf("---> %s\n", (char *)pl_args2[0]); } diff --git a/TP1/Prolog/AidesCPP/3-f.pl b/TP1/Prolog/AidesCPP/3-f.pl index f7047ce..79ad7a9 100644 --- a/TP1/Prolog/AidesCPP/3-f.pl +++ b/TP1/Prolog/AidesCPP/3-f.pl @@ -1,3 +1,3 @@ f(1). f(2). -f(10). \ No newline at end of file +f(10). diff --git a/TP1/Prolog/AidesCPP/3.cpp b/TP1/Prolog/AidesCPP/3.cpp index cd2dcd8..42d6bf4 100644 --- a/TP1/Prolog/AidesCPP/3.cpp +++ b/TP1/Prolog/AidesCPP/3.cpp @@ -1,11 +1,12 @@ -#include #include +#include // swipl-ld -ld g++ -goal true 3.cpp empty.pl // on retire 3-f.pl de la compile pour le charger à chq execution -// charger empty.pl (qui est vide) permet de ne pas avoir le message de bienvenu de Prolog +// charger empty.pl (qui est vide) permet de ne pas avoir le message de bienvenu +// de Prolog -int main(int _ac, char** _av) { +int main(int _ac, char **_av) { PL_initialise(_ac, _av); PlTermv pl_args(1); @@ -14,7 +15,7 @@ int main(int _ac, char** _av) { PlTermv pl_args2(1); PlQuery q0("f", pl_args2); - while( q0.next_solution()) { + while (q0.next_solution()) { printf("---> %s\n", (char *)pl_args2[0]); } diff --git a/TP1/Prolog/AidesCPP/4.cpp b/TP1/Prolog/AidesCPP/4.cpp index 1c557f8..2e2e2ed 100644 --- a/TP1/Prolog/AidesCPP/4.cpp +++ b/TP1/Prolog/AidesCPP/4.cpp @@ -1,9 +1,9 @@ -#include #include +#include // swipl-ld -ld g++ -goal true 4.cpp empty.pl -int main(int _ac, char** _av) { +int main(int _ac, char **_av) { printf("using fac.pl to compute 10!\n"); PL_initialise(_ac, _av); @@ -14,7 +14,7 @@ int main(int _ac, char** _av) { PlTermv pl_args2(2); pl_args2[0] = 10; PlQuery q0("fac", pl_args2); - while( q0.next_solution()) { + while (q0.next_solution()) { printf("---> %d\n", (int)pl_args2[1]); } diff --git a/TP1/Prolog/AidesCPP/fac.pl b/TP1/Prolog/AidesCPP/fac.pl index 4a579f0..99dd011 100644 --- a/TP1/Prolog/AidesCPP/fac.pl +++ b/TP1/Prolog/AidesCPP/fac.pl @@ -5,4 +5,4 @@ fac(X,F):- fac( Y, Next ), F is X * Next. -% ?- fac(3, X). \ No newline at end of file +% ?- fac(3, X).