Show
Ignore:
Timestamp:
04/22/08 08:09:59 (4 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/numberlist.lgt

    r3567 r4216  
    55 
    66    :- info([ 
    7         version is 1.1, 
     7        version is 1.2, 
    88        author is 'Paulo Moura', 
    9         date is 2007/4/20, 
     9        date is 2008/4/22, 
    1010        comment is 'List of numbers predicates.']). 
    1111 
     
    5757        sum(Ns, Acc2, Sum). 
    5858 
    59     valid(List) :- 
    60         nonvar(List), 
    61         \+ \+ valid2(List). 
    62  
    63     valid2([]). 
    64     valid2([Head| Tail]) :- 
    65         number(Head), 
    66         valid2(Tail). 
     59    valid(-) :-     % catch variables and lists with unbound tails 
     60        !, 
     61        fail. 
     62    valid([]). 
     63    valid([Element| List]) :- 
     64        number(Element), 
     65        valid(List). 
    6766 
    6867:- end_object.