Question: PROLOG without any pre-defined predicates! Write a Prolog rule for the predicate elimdup(L1,L2), which eliminates duplicate elements from a list. L1 is a given list
PROLOG without any pre-defined predicates! Write a Prolog rule for the predicate elimdup(L1,L2), which eliminates duplicate elements from a list. L1 is a given list of elements, and L2 is used to store the result.
Examples:
?- elimdup([1, 3, 5, 3], R).
yes, R = [1,3,5]
?- elimdup([a, b, a, c, b], R).
yes, R = [a, b, c]
//must be in this order.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
