Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to find summation of list of numbers

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

Prolog program to find summation of list of numbers.

Code for Prolog program to find summation of list of numbers in Artificial Intelligence

trace
domains
    l = integer*
predicates
    sum(l)
    findsum(l,integer)
clauses

    sum(List):-
        X=0,
        findsum(List,X).
    
    findsum([],X):-
        write("X::",X).
    findsum([H|List],X):-
        XX = X+H,
        findsum(List,XX).
  
Share: 


Didn't find what you were looking for? Find more on Prolog program to find summation of list of numbers Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of Prolog program to find summation of list of numbers 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!