|
Revision 4482, 0.8 KB
(checked in by pmoura, 7 weeks ago)
|
|
Modified the implementation of the predicate product/2 in the library object "numberlist" to fail for empty lists.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | :- protocol(numberlistp). |
|---|
| 3 | |
|---|
| 4 | :- info([ |
|---|
| 5 | version is 1.2, |
|---|
| 6 | author is 'Paulo Moura', |
|---|
| 7 | date is 2008/9/15, |
|---|
| 8 | comment is 'List of numbers protocol.']). |
|---|
| 9 | |
|---|
| 10 | :- public(product/2). |
|---|
| 11 | :- mode(product(+list(number), ?number), zero_or_one). |
|---|
| 12 | :- info(product/2, |
|---|
| 13 | [comment is 'Calculates the product of all list numbers. Fails if the list is empty.', |
|---|
| 14 | argnames is ['List', 'Product']]). |
|---|
| 15 | |
|---|
| 16 | :- public(sum/2). |
|---|
| 17 | :- mode(sum(+list(number), ?number), one). |
|---|
| 18 | :- info(sum/2, |
|---|
| 19 | [comment is 'Calculates the sum of all list numbers. Returns zero if the list is empty.', |
|---|
| 20 | argnames is ['List', 'Sum']]). |
|---|
| 21 | |
|---|
| 22 | :- public(average/2). |
|---|
| 23 | :- mode(average(+list(number), ?float), zero_or_one). |
|---|
| 24 | :- info(average/2, |
|---|
| 25 | [comment is 'Calculates the average (i.e. arithmetic mean) of a list of numbers. Fails if the list is empty.', |
|---|
| 26 | argnames is ['List', 'Average']]). |
|---|
| 27 | |
|---|
| 28 | :- end_protocol. |
|---|