SlideShare a Scribd company logo
1 of 2
Download to read offline
/* 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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 11 library

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

Similar to 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
 

More from 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 ...
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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...
 
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
 

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]