% Last item of a given list..... % Alamgir Hossain, CSE, JUST namelist = symbol* lastd(namelist,symbol). lastd([Head],X):- X = Head. lastd([_|Tail],X):- lastd(Tail,X). % End of code
% Output---------
%Input :
% : lastd([a,b,c,d],X).
% output : X = d
% Last item of a given list..... % Alamgir Hossain, CSE, JUST namelist = symbol* lastd(namelist,symbol). lastd([Head],X):- X = Head. lastd([_|Tail],X):- lastd(Tail,X). % End of code
No comments:
Post a Comment