Show
Ignore:
Timestamp:
10/04/08 12:30:36 (3 months ago)
Author:
pmoura
Message:

Modified the implementation of the predicate product/2 in the library object "numberlist" to fail for empty lists.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/library/numberlistp.lgt

    r3567 r4482  
    33 
    44    :- info([ 
    5         version is 1.1, 
     5        version is 1.2, 
    66        author is 'Paulo Moura', 
    7         date is 2007/4/20, 
     7        date is 2008/9/15, 
    88        comment is 'List of numbers protocol.']). 
    99 
     
    1111    :- mode(product(+list(number), ?number), zero_or_one). 
    1212    :- info(product/2, 
    13         [comment is 'Calculates the product of all list values.', 
     13        [comment is 'Calculates the product of all list numbers. Fails if the list is empty.', 
    1414         argnames is ['List', 'Product']]). 
    1515 
    1616    :- public(sum/2). 
    17     :- mode(sum(+list(number), ?number), zero_or_one). 
     17    :- mode(sum(+list(number), ?number), one). 
    1818    :- info(sum/2, 
    19         [comment is 'Calculates the sum of all list values.', 
     19        [comment is 'Calculates the sum of all list numbers. Returns zero if the list is empty.', 
    2020         argnames is ['List', 'Sum']]). 
    2121 
     
    2323    :- mode(average(+list(number), ?float), zero_or_one). 
    2424    :- info(average/2, 
    25         [comment is 'Calculates the average of a list  of values.', 
     25        [comment is 'Calculates the average (i.e. arithmetic mean) of a list of numbers. Fails if the list is empty.', 
    2626         argnames is ['List', 'Average']]). 
    2727