Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to check whether a list is an ordered list or not

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

Prolog program to check whether a list is an ordered list or not.

Code for Prolog program to check whether a list is an ordered list or not in Artificial Intelligence

domains
    x = integer
    l = integer*
    
predicates
    ordered(l)
    
clauses
    ordered([X]).
    
    ordered([Head|[Head1|Tail]]) :-
        Head <= Head1,
        ordered([Head1|Tail]).
        
Output : 

Goal: ordered([1,2,3,4])
Yes

Goal: ordered([3,2,4,5])
No
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to check whether a list is an ordered list or not is from India.
 
View All Articles

Related Articles and Code:


 
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!