SlideShare a Scribd company logo
1 of 1
Download to read offline
Prolog function
Solution
if u use built_in intersection method it doesn't work. avoid built_in intersection method.
solution:-
intersect([], X, [])
intersect(X|T,[],[])
intersect([X|T],Y,Z):-member(X,T),!,intersect(T,X,Z)
intersect([X|T],Y,[X|Z]):-member(X,Y),!,intersect(T,Y,Z)
intersect([X|T],Y,Z):-not(member(X,T)),intersect(T,X,Y)
member(X,[X|Z])
member(X,[X|Y]):-member(X,Y)

More Related Content

More from arpaqindia

Discuss the recruitment and selection procedure done by human resour.pdf
Discuss the recruitment and selection procedure done by human resour.pdfDiscuss the recruitment and selection procedure done by human resour.pdf
Discuss the recruitment and selection procedure done by human resour.pdf
arpaqindia
 
Describe the nutritional modes of organisms based upon where they obt.pdf
Describe the nutritional modes of organisms based upon where they obt.pdfDescribe the nutritional modes of organisms based upon where they obt.pdf
Describe the nutritional modes of organisms based upon where they obt.pdf
arpaqindia
 
Consider three genes in a hypothetical bird. One controls the color o.pdf
Consider three genes in a hypothetical bird. One controls the color o.pdfConsider three genes in a hypothetical bird. One controls the color o.pdf
Consider three genes in a hypothetical bird. One controls the color o.pdf
arpaqindia
 
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdf
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdfBook Business Its Legal, Ethical, Global Environment 10th Edition.pdf
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdf
arpaqindia
 
According the United States (U.S.) Centers for Disease Control and P.pdf
According the United States (U.S.) Centers for Disease Control and P.pdfAccording the United States (U.S.) Centers for Disease Control and P.pdf
According the United States (U.S.) Centers for Disease Control and P.pdf
arpaqindia
 
You are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdf
arpaqindia
 
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
arpaqindia
 

More from arpaqindia (20)

Discuss the recruitment and selection procedure done by human resour.pdf
Discuss the recruitment and selection procedure done by human resour.pdfDiscuss the recruitment and selection procedure done by human resour.pdf
Discuss the recruitment and selection procedure done by human resour.pdf
 
Do The statement of stockholders equity explains changes in equity.pdf
Do The statement of stockholders equity explains changes in equity.pdfDo The statement of stockholders equity explains changes in equity.pdf
Do The statement of stockholders equity explains changes in equity.pdf
 
Describe what is meant by “radical cure” and identify the drug that .pdf
Describe what is meant by “radical cure” and identify the drug that .pdfDescribe what is meant by “radical cure” and identify the drug that .pdf
Describe what is meant by “radical cure” and identify the drug that .pdf
 
Describe the nutritional modes of organisms based upon where they obt.pdf
Describe the nutritional modes of organisms based upon where they obt.pdfDescribe the nutritional modes of organisms based upon where they obt.pdf
Describe the nutritional modes of organisms based upon where they obt.pdf
 
Decasper and Spence (1986) measured babies sucking rates as they lis.pdf
Decasper and Spence (1986) measured babies sucking rates as they lis.pdfDecasper and Spence (1986) measured babies sucking rates as they lis.pdf
Decasper and Spence (1986) measured babies sucking rates as they lis.pdf
 
Corhin Eckles and Connor Hayes have recieved walkie talkies for Chri.pdf
Corhin Eckles and Connor Hayes have recieved walkie talkies for Chri.pdfCorhin Eckles and Connor Hayes have recieved walkie talkies for Chri.pdf
Corhin Eckles and Connor Hayes have recieved walkie talkies for Chri.pdf
 
Consider three genes in a hypothetical bird. One controls the color o.pdf
Consider three genes in a hypothetical bird. One controls the color o.pdfConsider three genes in a hypothetical bird. One controls the color o.pdf
Consider three genes in a hypothetical bird. One controls the color o.pdf
 
Answer the following questions What is the domain of logarithmic fun.pdf
Answer the following questions What is the domain of logarithmic fun.pdfAnswer the following questions What is the domain of logarithmic fun.pdf
Answer the following questions What is the domain of logarithmic fun.pdf
 
are organic compounds that bind very tightly to iron ions for transp.pdf
are organic compounds that bind very tightly to iron ions for transp.pdfare organic compounds that bind very tightly to iron ions for transp.pdf
are organic compounds that bind very tightly to iron ions for transp.pdf
 
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdf
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdfBook Business Its Legal, Ethical, Global Environment 10th Edition.pdf
Book Business Its Legal, Ethical, Global Environment 10th Edition.pdf
 
According the United States (U.S.) Centers for Disease Control and P.pdf
According the United States (U.S.) Centers for Disease Control and P.pdfAccording the United States (U.S.) Centers for Disease Control and P.pdf
According the United States (U.S.) Centers for Disease Control and P.pdf
 
9. For some non-Mendelian inheritance patterns, the genotype of an i.pdf
9. For some non-Mendelian inheritance patterns, the genotype of an i.pdf9. For some non-Mendelian inheritance patterns, the genotype of an i.pdf
9. For some non-Mendelian inheritance patterns, the genotype of an i.pdf
 
You have mated a phenotypically wild-type female of the genotype Xy+.pdf
You have mated a phenotypically wild-type female of the genotype Xy+.pdfYou have mated a phenotypically wild-type female of the genotype Xy+.pdf
You have mated a phenotypically wild-type female of the genotype Xy+.pdf
 
You are an oncologist specializing in colon cancer. A patient presen.pdf
You are an oncologist specializing in colon cancer. A patient presen.pdfYou are an oncologist specializing in colon cancer. A patient presen.pdf
You are an oncologist specializing in colon cancer. A patient presen.pdf
 
You are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdf
 
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
1.Which of Marys cranial nerves is affected in this episode( Mary.pdf
 
Which phyla have stomata and guard cells Bryophyta Monilophyta Co.pdf
Which phyla have stomata and guard cells  Bryophyta  Monilophyta  Co.pdfWhich phyla have stomata and guard cells  Bryophyta  Monilophyta  Co.pdf
Which phyla have stomata and guard cells Bryophyta Monilophyta Co.pdf
 
Which of the follwing traits would you expect to find in the transit.pdf
Which of the follwing traits would you expect to find in the transit.pdfWhich of the follwing traits would you expect to find in the transit.pdf
Which of the follwing traits would you expect to find in the transit.pdf
 
What is DNA fingerprintingPlease, no wikipedia or google definiti.pdf
What is DNA fingerprintingPlease, no wikipedia or google definiti.pdfWhat is DNA fingerprintingPlease, no wikipedia or google definiti.pdf
What is DNA fingerprintingPlease, no wikipedia or google definiti.pdf
 
What are parametric and nonparametric inferential testsSolution.pdf
What are parametric and nonparametric inferential testsSolution.pdfWhat are parametric and nonparametric inferential testsSolution.pdf
What are parametric and nonparametric inferential testsSolution.pdf
 

Recently uploaded

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 

Prolog functionSolutionif u use built_in intersection method i.pdf

  • 1. Prolog function Solution if u use built_in intersection method it doesn't work. avoid built_in intersection method. solution:- intersect([], X, []) intersect(X|T,[],[]) intersect([X|T],Y,Z):-member(X,T),!,intersect(T,X,Z) intersect([X|T],Y,[X|Z]):-member(X,Y),!,intersect(T,Y,Z) intersect([X|T],Y,Z):-not(member(X,T)),intersect(T,X,Y) member(X,[X|Z]) member(X,[X|Y]):-member(X,Y)