Question: Question 6 [ 1 5 ] Let L 1 , L 2 and L denote lists of terms. Write Prolog programs to realise the following:
Question
Let L L and L denote lists of terms. Write Prolog programs to realise the following:
Note that the lengths of lists L and L should be equal in all cases:
a Interleave alternate elements of L and L into L
For example, if Labc and L
then L abc
Are the inputoutput roles of variables in your program reversible?
b Transpose L and L into L That is if Labc and L then
L abc
Are the inputoutput roles of your variables reversible?
c Suppose that L and L are lists of numeric values. Write a procedure
innerprodLLX that defines X to be the innerproduct of the two vectors L
and L
The innerproduct X is calculated as follows:
If we have two vectors a a an and b b bn then
X atimes b atimes b antimes bn
Are the inputoutput roles of the variable in your program reversible?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
