Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to write the elements of the list line by line

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

Prolog program to write the elements of the list line by line.

Code for Prolog program to write the elements of the list line by line in Artificial Intelligence

domains
    l = integer*
    
predicates
    printlist(l)
    
clauses
    printlist([]).
    
    printlist([X|List]) :-
        write(X),nl,
        printlist(List).

    
Output :

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



Milind Mishra
Milind Mishra author of Prolog program to write the elements of the list line by line is from India.
 
View All Articles

 
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!