move term_variables to builtins
This commit is contained in:
@@ -153,7 +153,7 @@ The following predicates are built-in to rusty-wam.
|
|||||||
* `member/2`
|
* `member/2`
|
||||||
* `memberchk/2`
|
* `memberchk/2`
|
||||||
* `nonvar/1`
|
* `nonvar/1`
|
||||||
* `numbervars/{2,3}`
|
* `numbervars/2`
|
||||||
* `once/1`
|
* `once/1`
|
||||||
* `partial_string/2`
|
* `partial_string/2`
|
||||||
* `rational/1`
|
* `rational/1`
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
:- op(400, yfx, /).
|
:- op(400, yfx, /).
|
||||||
|
|
||||||
:- module(builtins, [(=)/2, (+)/2, (**)/2, (*)/2, (-)/2, (/)/2, (/\)/2,
|
:- module(builtins, [(=)/2, (+)/2, (**)/2, (*)/2, (-)/2, (/)/2,
|
||||||
(\/)/2, (is)/2, (xor)/2, (div)/2, (//)/2, (rdiv)/2, (<<)/2,
|
(/\)/2, (\/)/2, (is)/2, (xor)/2, (div)/2, (//)/2, (rdiv)/2,
|
||||||
(>>)/2, (mod)/2, (rem)/2, (>)/2, (<)/2, (=\=)/2, (=:=)/2,
|
(<<)/2, (>>)/2, (mod)/2, (rem)/2, (>)/2, (<)/2, (=\=)/2,
|
||||||
(-)/1, (>=)/2, (=<)/2, (,)/2, (->)/2, (;)/2, (=..)/2, (==)/2,
|
(=:=)/2, (-)/1, (>=)/2, (=<)/2, (,)/2, (->)/2, (;)/2, (=..)/2,
|
||||||
(\==)/2, (@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2, (\=@=)/2,
|
(==)/2, (\==)/2, (@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2,
|
||||||
(:)/2, call_with_inference_limit/3, catch/3,
|
(\=@=)/2, (:)/2, call_with_inference_limit/3, catch/3,
|
||||||
current_prolog_flag/2, set_prolog_flag/2,
|
current_prolog_flag/2, set_prolog_flag/2,
|
||||||
setup_call_cleanup/3, throw/1, true/0, false/0]).
|
setup_call_cleanup/3, term_variables/2, throw/1, true/0,
|
||||||
|
false/0]).
|
||||||
|
|
||||||
/* this is an implementation specific declarative operator used to implement call_with_inference_limit/3
|
/* this is an implementation specific declarative operator used to implement call_with_inference_limit/3
|
||||||
and setup_call_cleanup/3. switches to the default trust_me and retry_me_else. Indexing choice
|
and setup_call_cleanup/3. switches to the default trust_me and retry_me_else. Indexing choice
|
||||||
@@ -205,6 +206,8 @@ get_args([Arg|Args], Func, I0, N) :-
|
|||||||
'$call_with_default_policy'(I1 is I0 + 1),
|
'$call_with_default_policy'(I1 is I0 + 1),
|
||||||
'$call_with_default_policy'(get_args(Args, Func, I1, N)).
|
'$call_with_default_policy'(get_args(Args, Func, I1, N)).
|
||||||
|
|
||||||
|
term_variables(Term, Vars) :- '$term_variables'(Term, Vars).
|
||||||
|
|
||||||
% setup_call_cleanup.
|
% setup_call_cleanup.
|
||||||
|
|
||||||
setup_call_cleanup(S, G, C) :- '$get_b_value'(B),
|
setup_call_cleanup(S, G, C) :- '$get_b_value'(B),
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
:- module(terms, [term_variables/2, numbervars/2, numbervars/3]).
|
:- module(terms, [numbervars/2]).
|
||||||
|
|
||||||
term_variables(Term, Vars) :- '$term_variables'(Term, Vars).
|
|
||||||
|
|
||||||
numbervars(Term, N) :-
|
numbervars(Term, N) :-
|
||||||
integer(N),
|
integer(N),
|
||||||
term_variables(Term, Vars),
|
term_variables(Term, Vars),
|
||||||
numberlist(Vars, N, N1).
|
numberlist(Vars, N, N1).
|
||||||
|
|
||||||
numbervars(Term, N0, N) :-
|
|
||||||
integer(N0),
|
|
||||||
integer(N),
|
|
||||||
term_variables(Term, Vars),
|
|
||||||
numberlist(Vars, N0, N).
|
|
||||||
|
|
||||||
numberlist([], N,N).
|
numberlist([], N,N).
|
||||||
numberlist(['$VAR'(N0)|Vars], N0,N) :-
|
numberlist(['$VAR'(N0)|Vars], N0,N) :-
|
||||||
N1 is N0+1,
|
N1 is N0+1,
|
||||||
|
|||||||
Reference in New Issue
Block a user