Question: Define a recursive Prolog rule ( s ) remove _ them ( Lst 1 , Lst 2 , Result ) where Result is a list

Define a recursive Prolog rule(s) remove_them(Lst1, Lst2, Result) where Result is a list of the elements of the list Lst1 that do not appear in the list Lst2.
Write a Prolog rule clean_list/2 where the first argument is a list and the 2nd argument is a list of the numbers in the list. You will use this for #2 & #3.
For example:
1- clean_list([1,two,'three',four,5,6],X).
X =[1,5,6].
Write a Prolog rule get_values/2 which replaces all sub-lists of the first argument with the sum of its elements.
For example:
get_values([[1,2],3,[4,5]],[3,3,9])
In football, a touchdown is 6 points, a field goal is 3 points, a safety is 2 points and an extra point is 1 point. Also, the number of extra points must be less than or equal to the number of touchdowns. Write a prolog rule called fbscore/5 which has as arguments the number of touchdowns, field goals, safeties, extra points, and total points in a football game. For simplicity, you can assume that there is some maximum number of each type of scoring. You should not assume any particular variable is ground. For example:
fbscore(7,2,1,5, X).
% X =55.
fbscore(T, F, S, X,10).
% T = F, F = X, X =0,
% S =5.
We flatten a list L by first removing all lists within L and replacing them with their members. Write a Prolog rule flattenit/2 which flattens a list. For example:
:- flattenit([a,b,c,[d,e],f,[c, a, b]],[a,b,c,d,e,f,c,a,b]).
:- flattenit([1,2,3,4,[5,6,[7,8]]],[1,2,3,4,5,6,7,8]).
:- flattenit([1,2,[3,4,[5,6],7],8,[2,4,5,8]],[1,2,3,4,5,6,7,8,2,4,5,8]).
Note: there is a built-in called flatten - you should not use that in your answer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Certainly Lets break down each part of the question and provide the corresponding Prolog rules 1 Rec... View full answer

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!