Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A PROLOG QUESTION ! Write a predicate chop_up(List, NewList) that takes List and binds NewList to List with all sequences of successive increasing

THIS IS A PROLOG QUESTION !

Write a predicate chop_up(List, NewList) that takes List and binds NewList to List with all sequences of successive increasing whole numbers replaced by a two-item list containing only the first and last number in the sequence. An example of successive increasing whole numbers is:19,20,21,22. (Note that the numbers have to be successive in the sense of increasing by exactly 1 at each step.) For example:

?- chop_up([9,10,5,6,7,3,1], Result). Result = [[9, 10], [5, 7], 3, 1] ?- chop_up([1,3,2,3,4], Result). Result = [1, 3, [2, 4]]

In this example, the sequence 9,10 has been replaced by [9,10], the sequence 5,6,7 has been replaced by [5, 7], and 2,3,4 has been replaced by[2, 4].

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions