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:
Markus Triska
2021-11-26 17:11:35 +01:00
parent ca28f24e42
commit 6ba374c62b

View File

@@ -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.