Question

I'm using SWI-Prolog for the project. Define a predicate segregate/3 that takes a list of integers...

I'm using SWI-Prolog for the project.

Define a predicate segregate/3 that takes a list of integers as an argument 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 segregate(List, Even, Odd).

Examples:

?- segregate([8,7,6,5,4,3], Even, Odd).

Even = [8,6,4]

Odd = [7,5,3]

?- segregate([7,2,3,5,8], Even, Odd).

Even = [2,8]

Odd = [7,3,5]

?- segregate([-4,11,-7,9,0], Even, Odd).

Even = [-4,0]

Odd = [11,-7,9]

?- segregate([5,13,29], Even, Odd).

Even = []

Odd = []

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
I'm using SWI-Prolog for the project. Define a predicate segregate/3 that takes a list of integers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT