Feb 16, 2007 #1 lauraberishaj Programmer Feb 16, 2007 4 SE I'm new in Prolog, Can anybody help me how to calculate the sum of a list of lists? Thank You, Laura
Feb 17, 2007 Thread starter #2 lauraberishaj Programmer Feb 16, 2007 4 SE sum([], 0) :- !. sum(N, N) :- number(N), !. sum([H|T], N) :- sum(H, N1), sum(T, N2), N is N1 + N2. --Did it ..yeeeaaahhhh Upvote 0 Downvote
sum([], 0) :- !. sum(N, N) :- number(N), !. sum([H|T], N) :- sum(H, N1), sum(T, N2), N is N1 + N2. --Did it ..yeeeaaahhhh