SlideShare a Scribd company logo
Without using cut, write a predicate split/3 that splits a list of integers into two lists: one
containing the even ones, the other containing the odd ones.
For example: split([3,4,5,1,0,8,9],E,O)
should return:
E = [4,0,8]
O = [5,1,9].
Then try to improve the program, without changing its meaning, with the help of cut.
Solution
domains ls=integer* predicates split(ls,ls,ls) clauses split([],[],[]).
split([X|L],[X|E],O):- if(X%2== 0) else split(L,E,O).
split([X|L],E,[X|O):- split(L,E,O).

More Related Content

More from footstatus

tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdftree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
footstatus
 
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdfThe plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
footstatus
 
The region labeled with the letter B is transcribed into mRNA True.pdf
The region labeled with the letter B is transcribed into mRNA  True.pdfThe region labeled with the letter B is transcribed into mRNA  True.pdf
The region labeled with the letter B is transcribed into mRNA True.pdf
footstatus
 
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdfThe positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
footstatus
 
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdfa) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
footstatus
 
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdfQuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
footstatus
 
provide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdfprovide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdf
footstatus
 
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
Match the Statements below with bacteriological tests.  Eosin-methyle.pdfMatch the Statements below with bacteriological tests.  Eosin-methyle.pdf
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
footstatus
 
Many non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdfMany non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdf
footstatus
 
It has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdfIt has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdf
footstatus
 
Let R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdfLet R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdf
footstatus
 
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdfJudith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
footstatus
 
A population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdfA population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdf
footstatus
 
a local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdfa local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdf
footstatus
 
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdfA gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
footstatus
 
A man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdfA man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdf
footstatus
 
A culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdfA culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdf
footstatus
 
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdfa. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
footstatus
 
5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf
footstatus
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
footstatus
 

More from footstatus (20)

tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdftree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
 
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdfThe plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
 
The region labeled with the letter B is transcribed into mRNA True.pdf
The region labeled with the letter B is transcribed into mRNA  True.pdfThe region labeled with the letter B is transcribed into mRNA  True.pdf
The region labeled with the letter B is transcribed into mRNA True.pdf
 
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdfThe positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
 
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdfa) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
 
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdfQuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
 
provide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdfprovide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdf
 
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
Match the Statements below with bacteriological tests.  Eosin-methyle.pdfMatch the Statements below with bacteriological tests.  Eosin-methyle.pdf
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
 
Many non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdfMany non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdf
 
It has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdfIt has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdf
 
Let R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdfLet R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdf
 
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdfJudith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
 
A population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdfA population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdf
 
a local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdfa local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdf
 
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdfA gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
 
A man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdfA man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdf
 
A culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdfA culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdf
 
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdfa. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
 
5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
 

Recently uploaded

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

Without using cut, write a predicate split3 that splits a list of i.pdf

  • 1. Without using cut, write a predicate split/3 that splits a list of integers into two lists: one containing the even ones, the other containing the odd ones. For example: split([3,4,5,1,0,8,9],E,O) should return: E = [4,0,8] O = [5,1,9]. Then try to improve the program, without changing its meaning, with the help of cut. Solution domains ls=integer* predicates split(ls,ls,ls) clauses split([],[],[]). split([X|L],[X|E],O):- if(X%2== 0) else split(L,E,O). split([X|L],E,[X|O):- split(L,E,O).