SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
/* LIBRARY: quelques prédicats utiles ... */
delete(_,[],[]).
delete(X,[X|R],R):-!.
delete(X,[Y|R],[Y|R2]):- delete(X,R,R2).
append([],X,X).
append([U|X],Y,[U|Z]):- append(X,Y,Z).
member(X,[X|T]).
member(X,[_|T]):- member(X,T).
last(X,[X]).
last(X,[_|Y]):- last(X,Y).
order(A,B):- A=<B.
order(A,B):- A@=<B. /* @=< signifie: précède ou est
égal */
card([],0).
card([X|Y],N):- card(Y,N1), N is N1+1.
Exemples d'invocation et résultats obtenus :
?- delete(two,[one,three,two,five],X).
X = [one,three,five]
?- append([one,two],[three,four,five],X).
X = [one,two,three,four,five]
?- append(X,[three,four,five],[one,two,three,four,five]).
X = [one,two]
?- member(three,[one,two,three,four,five]).
yes
?- member(X,[one,two,three,four,five]).
X = one
X = two
X = three
X = four
X = five
split(H,[A|X],[A|Y],Z):- order(A,H),
split(H,X,Y,Z).
split(H,[A|X],Y,[A|Z]):- order(H,A),
split(H,X,Y,Z).
split(_,[],[],[]).
quisort([H|T],S):-
split(H,T,A,B),
quisort(A,A1),
quisort(B,B1),
append(A1,[H|B1],S),!.
quisort([],[]).
quisort([X],[X]).
nthmember(1,[X|L],X).
nthmember(N,[Y|L],X):- N1 is N-1, nthmember(N1, L, X
).
add(X,L,L):- member(X,L),!.
add(X,L,[X|L]).
remdup([X|Y],L):- member(X,Y), remdup(Y,L),!.
remdup([],[]).
remdup([X|Y],[X|Y1]):- not(member(X,Y)),
remdup(Y,Y1),.
*Veuillez consulter le fichier [Exemples/Fichier10.pl] du CD.
?- card([one,two,three,four,five],Combien).
Combien = 5
?- card([one,two,three,four,five],4).
No
?- nthmember(2,[one,two,three],X).
X = two
?- nthmember(1,[one,two,three],one).
yes
?- add(three,[one,four,five],New).
New = [three,one,four,five]
?- add(three,[one,two,three,four],New).
New = [one,two,three,four]
11 library

Contenu connexe

Tendances

Quadraticsportfoliopowerpoint 100325142401-phpapp02
Quadraticsportfoliopowerpoint 100325142401-phpapp02Quadraticsportfoliopowerpoint 100325142401-phpapp02
Quadraticsportfoliopowerpoint 100325142401-phpapp02
nurliyanazakaria
 
Creating a Table from a Function
Creating a Table from a FunctionCreating a Table from a Function
Creating a Table from a Function
dmidgette
 
Selective codes
Selective codesSelective codes
Selective codes
Siva Gopal
 

Tendances (20)

Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
Joclad 2010 d
Joclad 2010 dJoclad 2010 d
Joclad 2010 d
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Quadraticsportfoliopowerpoint 100325142401-phpapp02
Quadraticsportfoliopowerpoint 100325142401-phpapp02Quadraticsportfoliopowerpoint 100325142401-phpapp02
Quadraticsportfoliopowerpoint 100325142401-phpapp02
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
 
Creating a Table from a Function
Creating a Table from a FunctionCreating a Table from a Function
Creating a Table from a Function
 
Python Basics #1
Python Basics #1Python Basics #1
Python Basics #1
 
2D-Array
2D-Array 2D-Array
2D-Array
 
11 graphs of first degree functions x
11 graphs of first degree functions x11 graphs of first degree functions x
11 graphs of first degree functions x
 
Coding Test Review1
Coding Test Review1Coding Test Review1
Coding Test Review1
 
Multiplicacion de polinomios 1ro
Multiplicacion de polinomios   1roMultiplicacion de polinomios   1ro
Multiplicacion de polinomios 1ro
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Selective codes
Selective codesSelective codes
Selective codes
 
Mat lab lecture part 1
Mat lab lecture part 1Mat lab lecture part 1
Mat lab lecture part 1
 
10.5 more on language of functions x
10.5 more on language of functions x10.5 more on language of functions x
10.5 more on language of functions x
 

Similaire à 11 library

Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
league
 

Similaire à 11 library (20)

PrologListsGraphs.ppt
PrologListsGraphs.pptPrologListsGraphs.ppt
PrologListsGraphs.ppt
 
Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
 
Lesson 18
Lesson 18Lesson 18
Lesson 18
 
AI Lesson 18
AI Lesson 18AI Lesson 18
AI Lesson 18
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
 
The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)
 
1523 double integrals
1523 double integrals1523 double integrals
1523 double integrals
 
Millionways
MillionwaysMillionways
Millionways
 
The Essence of the Iterator Pattern
The Essence of the Iterator PatternThe Essence of the Iterator Pattern
The Essence of the Iterator Pattern
 
Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''
 
Secretary_Game_With_Rejection.pdf
Secretary_Game_With_Rejection.pdfSecretary_Game_With_Rejection.pdf
Secretary_Game_With_Rejection.pdf
 
Relations and functions
Relations and functionsRelations and functions
Relations and functions
 
Cubic BF-Algebra
Cubic BF-AlgebraCubic BF-Algebra
Cubic BF-Algebra
 
Hog processing
Hog processingHog processing
Hog processing
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
The java language cheat sheet
The java language cheat sheetThe java language cheat sheet
The java language cheat sheet
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 

Plus de Siham Rim Boudaoud (16)

12 quelques prédicats prédéfinis de swi
12  quelques prédicats prédéfinis de swi12  quelques prédicats prédéfinis de swi
12 quelques prédicats prédéfinis de swi
 
10 chapitre 4 listes et récursivité
10 chapitre 4 listes et récursivité10 chapitre 4 listes et récursivité
10 chapitre 4 listes et récursivité
 
9 gl2
9 gl29 gl2
9 gl2
 
8 gl1
8 gl18 gl1
8 gl1
 
8 arbre généalogique
8 arbre généalogique8 arbre généalogique
8 arbre généalogique
 
7
77
7
 
6 unification
6 unification6 unification
6 unification
 
5 installation de prolog
5 installation de prolog5 installation de prolog
5 installation de prolog
 
4 histoir
4 histoir4 histoir
4 histoir
 
3 intro
3 intro3 intro
3 intro
 
2
2 2
2
 
2 sommaire
2  sommaire2  sommaire
2 sommaire
 
1 page de garde
1 page de garde1 page de garde
1 page de garde
 
13 conclusion
13  conclusion13  conclusion
13 conclusion
 
Diapo. ite web dynamique sous JEE, application aux entreprises de production ...
Diapo. ite web dynamique sous JEE, application aux entreprises de production ...Diapo. ite web dynamique sous JEE, application aux entreprises de production ...
Diapo. ite web dynamique sous JEE, application aux entreprises de production ...
 
Mémoire de Licence, site web dynamique sous JEE, application aux entreprises ...
Mémoire de Licence, site web dynamique sous JEE, application aux entreprises ...Mémoire de Licence, site web dynamique sous JEE, application aux entreprises ...
Mémoire de Licence, site web dynamique sous JEE, application aux entreprises ...
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

11 library

  • 1. /* LIBRARY: quelques prédicats utiles ... */ delete(_,[],[]). delete(X,[X|R],R):-!. delete(X,[Y|R],[Y|R2]):- delete(X,R,R2). append([],X,X). append([U|X],Y,[U|Z]):- append(X,Y,Z). member(X,[X|T]). member(X,[_|T]):- member(X,T). last(X,[X]). last(X,[_|Y]):- last(X,Y). order(A,B):- A=<B. order(A,B):- A@=<B. /* @=< signifie: précède ou est égal */ card([],0). card([X|Y],N):- card(Y,N1), N is N1+1. Exemples d'invocation et résultats obtenus : ?- delete(two,[one,three,two,five],X). X = [one,three,five] ?- append([one,two],[three,four,five],X). X = [one,two,three,four,five] ?- append(X,[three,four,five],[one,two,three,four,five]). X = [one,two] ?- member(three,[one,two,three,four,five]). yes ?- member(X,[one,two,three,four,five]). X = one X = two X = three X = four X = five split(H,[A|X],[A|Y],Z):- order(A,H), split(H,X,Y,Z). split(H,[A|X],Y,[A|Z]):- order(H,A), split(H,X,Y,Z). split(_,[],[],[]). quisort([H|T],S):- split(H,T,A,B), quisort(A,A1), quisort(B,B1), append(A1,[H|B1],S),!. quisort([],[]). quisort([X],[X]). nthmember(1,[X|L],X). nthmember(N,[Y|L],X):- N1 is N-1, nthmember(N1, L, X ). add(X,L,L):- member(X,L),!. add(X,L,[X|L]). remdup([X|Y],L):- member(X,Y), remdup(Y,L),!. remdup([],[]). remdup([X|Y],[X|Y1]):- not(member(X,Y)), remdup(Y,Y1),. *Veuillez consulter le fichier [Exemples/Fichier10.pl] du CD. ?- card([one,two,three,four,five],Combien). Combien = 5 ?- card([one,two,three,four,five],4). No ?- nthmember(2,[one,two,three],X). X = two ?- nthmember(1,[one,two,three],one). yes ?- add(three,[one,four,five],New). New = [three,one,four,five] ?- add(three,[one,two,three,four],New). New = [one,two,three,four]