6. (20pt) Consider the following Prolog facts and rules:
append([], Y, Y).
append ( [H I X] Y, I Z] ) : - append(X, Y, Z) .
member (X, [X I _] ) .
member (X, [-IT]) :- member(X, T).
member2(X, L) append(P, [X I _] , L), not (member2(X, P)).
The member predicate returns all elements of a list when used as shown below (left). To produce each element only once, we can use member2; see below (middle). Note further that member2 produces unique elements in the order of their first occurrence.
?- member(X, [a,b,c,b,a]) . ?- member2(X, [a,b,c,b,a]). ?- member3(X, [a,b,c,b,a]).
X = a ; X = a ; X = c ;
X = b ; X = b ; X = b ;
X = c ; X = c ; X = a ;
X = a ; false. false.
X = a ;
false.
(a) (lOpt) Write a new predicate member3 which, when used as above, produces unique elements in the order of their last occurrence, as seen above (right).
(b) (lOpt) Draw the Prolog tree for the computation below: like in the examples we discussed, you need to show, on each brach, the rule used and the substitution (if any), the branches not attempted because of cuts (! - indicate which cut prevented which branch), and the output produced (solutions and the false).
?- member3(X, [a,b,a]).
X = b ;
X = a ;
false.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme