Answered step by step
Verified Expert Solution
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 rules removethemLst Lst Result where Result is a list of the elements of the list Lst that do not appear in the list Lst
Write a Prolog rule cleanlist where the first argument is a list and the nd argument is a list of the numbers in the list. You will use this for # & #
For example:
cleanlisttwo,'three',four,X
X
Write a Prolog rule getvalues which replaces all sublists of the first argument with the sum of its elements.
For example:
getvalues
In football, a touchdown is points, a field goal is points, a safety is points and an extra point is point. Also, the number of extra points must be less than or equal to the number of touchdowns. Write a prolog rule called fbscore 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 X
X
fbscoreT F S X
T F F X X
S
We flatten a list L by first removing all lists within L and replacing them with their members. Write a Prolog rule flattenit which flattens a list. For example:
: flattenitabcdefc a babcdefcab
: flattenit
: flattenit
Note: there is a builtin called flatten you should not use that in your answer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started