mem(X,X!Y) mem(X,Y!Z) :- mem(X,Z) append(nil,Y,Y) append(X!Y,Z,X!W) :- append(Y,Z,W)