====== List sum ====== {{tag>arithmetic lists}} ===== Description ===== Determining the length of a list using stack. **Source**: PROLOG str. 195 Wydawnictwo PLJ Warszawa 1991 ISBN 83-85190-63-5 ===== Download ===== Program source code: {{list_sum.pl}} ===== Listing ===== suma([], Sum, Sum, Ilosc, Ilosc). suma([H|T], Sum, Sum1, Ilosc, Ilosc1) :- Nilosc is Ilosc + 1, Nsuma is Sum1 + H, suma(T, Sum, Nsuma, Ilosc, Nilosc). test :- suma([1, 2, 3, 4, 4, 5], S, 0, Ilosc, 0). ===== Comments =====