(Solved) : Write Two Clauses Prolog Determines Exactly Two Values List Sum Value N Output Single True Q37280350 . . .
Write two clauses in Prolog that determines if there are exactlytwo values in a list such that they sum a value N. The outputshould be a single true if there exists two values whose sum is Nor a single false if there are not. If there are multiple valueswhose sum is N then your program should only print true once.
Sample
List [1, 3, 5, 7] with N equal to 10 should print true. 7 + 3 =10.
List [1, 3, 5, 7] with N equal to 20 should print false. No twovalues sum is 20.
List [7, 1, 10, 3, 8, 2] with N equal to 9 should print true. 2 + 7= 9 and 8 + 1 = 9 and 1 + 8 = 9 and 7 + 2 = 9.
Restrictions
You are restricted to the following.
· Use of at most2 clauses.
· +
· ,
· ;
· .
· !
· :-
· is
· Lists
· Head and tailsyntax for list types
· Variables
Expert Answer
Answer to Write two clauses in Prolog that determines if there are exactly two values in a list such that they sum a value N. The …
OR