Show
Ignore:
Timestamp:
04/22/08 08:09:59 (6 months ago)
Author:
pmoura
Message:

Updated the definitions of the predicate valid/1 for the library objects "list", "list(Type)", "numberlist", "set", "set(Type)", "varlist" to fail for lists with unbound tails after discussion with Jan Wielemaker and Ulrich Neumerkel.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/library/list1.lgt

    r2737 r4216  
    44 
    55    :- info([ 
    6         version is 1.01, 
     6        version is 1.1, 
    77        author is 'Paulo Moura', 
    8         date is 2006/4/25, 
     8        date is 2008/4/22, 
    99        comment is 'List predicates with elements constrained to a single type.']). 
    1010 
    11     valid(List) :- 
    12         nonvar(List), 
     11    valid(-) :-     % catch variables and lists with unbound tails 
     12        !, 
     13        fail. 
     14    valid([]). 
     15    valid([Element| List]) :- 
    1316        parameter(1, Type), 
    14         \+ \+ valid(List, Type). 
    15  
    16     valid([], _). 
    17     valid([Value| List], Type) :- 
    18         Type::valid(Value), 
    19         valid(List, Type). 
     17        Type::valid(Element), 
     18        valid(List). 
    2019 
    2120:- end_object.