% Write a Prolog program to implement reverse(List,ReversedList) that reverses
% lists.
/* Reverse of the list. */
reverse([H|T],R):-
length(T,L),
L>0 ->
(
reverse(T,R1),
/* write(R1), */
R is H
)
;
R is H.
% Output
|
Prolog Program to reverse the elements in the list. |
wrong output :
ReplyDelete1 ?- reverse([1,2,3,4],R).
R = 1.
Bro it's working. You can see the Output image.
Deleteya it's working.
ReplyDeleteSorry to say, but this code is not showing the correct output
ReplyDeleteCan you please mention the case for which you're not getting the correct output?
Delete