Write a Prolog program to implement reverse (L, R) where List L is original and List R is reversed list.

12.Write a Prolog program to implement reverse (L, R) where List L is original and List R is reversed list.

% Write a Prolog program to implement reverse (L, R) where List L is original 
  and List R is reversed list.

%  below reverse_list and reverse function is not predefined you can use any name as function

reverse_list(Inputlist,Outputlist):-
reverse(Inputlist,[],Outputlist).    
reverse([],Outputlist,Outputlist).    
reverse([Head|Tail],List1,List2):-
reverse(Tail,[Head|List1],List2).

% Output


1 comment:

  1. auto-accident-compensation-claims-in-michigan When needing to hire a car accident lawyer, you want someone you can trust to see your case through to the end.
    car-accident-lawyer-san-fernando-valley When needing to hire a car accident lawyer, you want someone you can trust to see your case through to the end.
    eiffel tower macau Aurecon was involved in the design and design of the unique new structure. We provided complete structural engineering advice for the project and assisted with keeping the original design.
    car-accident-lawyer-columbus-ga Although the aftermath of a car accident may only last for a second, the physical, financial, and emotional consequences of a wreck can last for the rest of your life.

    ReplyDelete

Featured post

Amazon Interview Process

On July 5, 1994, Jeff Bezos started the world's most "customer-centric" firm out of his garage in Bellevue, Washington. The A...