CLOUD COMPUTING | DATA MINING | ARTIFICIAL INTELLIGENCE | APPLICATION PROGRAMMING IN C/C++/Java
Wednesday, May 4, 2011
PROGRAM TO ADD 10 ELEMENTS OF LIST
% IT WILL WORK FOR 10 ELEMNTS AND TO MAKE IT WORK FOR ANY NUMBER PLACE A %NUMBER IN PLACE OF 10 WHATR U WANT.
addlist(_,0,0).
addlist([H|T],C,X):-C1 is C-1,addlist(T,C1,X1),X is X1+H.
sum([H|T],X):-addlist([H|T],10,X).
No comments:
Post a Comment