ITEC 380 - Some Prolog List Functions
% Here are some sample list functions for you to think about:


member(X, [X|_]).
member(X, [_|L]) :- member(X,L).


rev([],[]).
rev([Head|Tail], List) :- rev(Tail, List2), append(List2, [Head], List).


append([],List, List).
append([Head|L1], L2, [Head|L3]) :- append(L1, L2, L3).


printlist([]) :- nl.
printlist([Head|Tail]) :- write(Head), printlist(Tail).





Last modified on