ENHANCED: use '$skip_max_list'/4 for fast list tests in can_be/2 and must_be/2
This also (partially) addresses #1108.
This commit is contained in:
@@ -79,9 +79,12 @@ character(C) :-
|
|||||||
atom(C),
|
atom(C),
|
||||||
atom_length(C, 1).
|
atom_length(C, 1).
|
||||||
|
|
||||||
ilist(V) :- var(V), instantiation_error(must_be/2).
|
ilist(Ls) :-
|
||||||
ilist([]).
|
'$skip_max_list'(_, -1, Ls, Rs),
|
||||||
ilist([_|Ls]) :- ilist(Ls).
|
( var(Rs) ->
|
||||||
|
instantiation_error(must_be/2)
|
||||||
|
; Rs == []
|
||||||
|
).
|
||||||
|
|
||||||
type(type).
|
type(type).
|
||||||
type(integer).
|
type(integer).
|
||||||
@@ -120,10 +123,11 @@ can_(chars, Ls) :- '$is_partial_string'(Ls).
|
|||||||
can_(list, Term) :- list_or_partial_list(Term).
|
can_(list, Term) :- list_or_partial_list(Term).
|
||||||
can_(boolean, Term) :- boolean(Term).
|
can_(boolean, Term) :- boolean(Term).
|
||||||
|
|
||||||
list_or_partial_list(Var) :- var(Var).
|
list_or_partial_list(Ls) :-
|
||||||
list_or_partial_list([]).
|
'$skip_max_list'(_, -1, Ls, Rs),
|
||||||
list_or_partial_list([_|Ls]) :-
|
( var(Rs) -> true
|
||||||
list_or_partial_list(Ls).
|
; Rs == []
|
||||||
|
).
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Shorthands for throwing ISO errors.
|
Shorthands for throwing ISO errors.
|
||||||
|
|||||||
Reference in New Issue
Block a user