20_09

Write a Prolog program to implement reverse(List,ReversedList) that reverses lists.

 Source Code :

 

arev([],L,L).

arev([H|T],A,R):-

     arev(T,[H|A],R).

rev(L1,L2):-

     arev(L1,[],L2).

 

 

Output :

 

Prolog program to implement reverse(List,ReversedList) that reverses lists

No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...