Aim: Write a Prolog program to find the sum of elements of a list.
Prolog Program Code:
domains
X=integer
l=integer*
predicates
sum(l,X)
clauses
sum([],0).
sum([X|List],sum):-sum(List,sum1),
sum=X+sum1.
domains
X=integer
l=integer*
predicates
sum(l,X)
clauses
sum([],0).
sum([X|List],sum):-sum(List,sum1),
sum=X+sum1.
0 Comments