Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to reverse a given List

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 4251

Prolog program to reverse a given List.

Code for Prolog program to reverse a given List in Artificial Intelligence

domains
    l = integer*

predicates
    reverse_list(l,l)
    reverse(l,l,l)
    
clauses
    reverse_list(IN,OUT) :-
        reverse(IN,[],OUT).
    reverse([],IN,IN).
    reverse([Head|Tail],List1,List2) :-
        reverse(Tail,[Head|List1],List2).
  
Share: 


Didn't find what you were looking for? Find more on Prolog program to reverse a given List Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of Prolog program to reverse a given List is from India.
 
View All Articles

 

Other Interesting Articles in Artificial Intelligence:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!