Question: /* Problem 3: Write a predicate init(All, BLst) that succeeds if Blst has all the items of ALL except the last item. The items in

/* Problem 3: Write a predicate init(All, BLst) that succeeds if Blst has all the items of ALL except the last item. The items in BLst are in the same order as ALL. */

init([_], []). init([X, _], [X]). init([H|T], [H|BLst]) :- init(T, BLst).

/* Problem 3 Test: */ :- init([1], []). % SUCCEED :- init([1,2,3], [1,2]).% SUCCEED :- init([1,2], [1,2]) -> fail ; true. % FAIL :- init([1,2], [2]) -> fail ; true. % FAIL

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!