Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:list_sum_3 [2019/06/27 15:50]
pl:prolog:pllib:list_sum_3 [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== List sum 3 ======
 +{{tag>​lists arithmetic}}
 +===== Description =====
 +Iterative version of summing a list of integers using an accumulator. ​
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{list_sum_3.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 +   ​sumlist(Is,​Sum) :- Sum is the sum of the list of integers Is.
 +*/
 +     ​sumlist(Is,​Sum) :- sumlist(Is,​0,​Sum).
 +
 +     ​sumlist([I|Is],​Temp,​Sum) :- 
 + Temp1 is Temp+I, sumlist(Is,​Temp1,​Sum).
 +     ​sumlist([],​Sum,​Sum).
 +
 +%  Program 8.6b   ​Iterative version of summing a list of integers
 +% using an accumulator
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/list_sum_3.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0