Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago