% prolog program for reverse a given list------ % Alamgir Hossain, CSE, JUST list([H|T],Result):- reverselist(T, [H], Result). reverselist([], Acc, Acc). reverselist([H|T], Acc, Result):- reverselist(T, [H|Acc], Result). % End of code
% Go to console and check the result
% Input :
% list([1,2,3,43,6,7,90,100],Result).
%Output:
%Result = [100,90,7,6,43,3,2,1]
No comments:
Post a Comment