Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to check whether a given word is a palindrome or not

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

Prolog program to check whether a given word is a palindrome or not.

Code for Prolog program to check whether a given word is a palindrome or not in Artificial Intelligence

domains 
    x = char
    l = char*
    
predicates
    palindrome(l)
    reverse(l,l)
    concatenate(l,l,l)
    
clauses
    concatenate([],List,List).
    
    concatenate([X|List1],List2,[X|List3]) :-
        concatenate(List1,List2,List3).
        
    reverse([],[]).
    
    reverse([X|Tail],List) :-
        reverse(Tail,Tail1),
        concatenate(Tail1,[X],List).
        
    palindrome(List) :-
        reverse(List,List).
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to check whether a given word is a palindrome or not 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!