Question: Please Solve using PROLOG Define a predicate classify/3 that takes a list of integers as an parameter and generates two lists, the first containing containing

Please Solve using PROLOG

Define a predicate classify/3 that takes a list of integers as an parameter and generates two lists, the first containing containing the even numbers from the original list and the second sublist containing the odd numbers from the original list. Your predicate should have the signature classify(List, Even, Odd).

Examples:

classify([8,7,6,5,4,3], Even, Odd). Even = [8,6,4] Odd = [7,5,3] 
?- classify([7,2,3,5,8], Even, Odd). Even = [2,8] Odd = [7,3,5] 
?- classify([-4,11,-7,9,0], Even, Odd). Even = [-4,0] Odd = [11,-7,9] 
?- classify([5,13,29], Even, Odd). Even = [] Odd = [5,13,29] 
?- classify([], Even, Odd). Even = [] Odd = [] 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!