-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck0.pro
38 lines (32 loc) · 862 Bytes
/
check0.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** <module> a little checking
See also library(error).
*/
:- module(check0, [
check_term/2
]).
/** check_term(?Check, ?Term)
"Run Check on Term."
Check is any of:
- var: an unbound variable
- nonvar: a bound variable, a partially ground term, a ground term, everything that is not an unbound variable
- ground
- integer
- atom
- string
- A + B: check A or check B
Term may be anything.
Example:
```
check_term(var, A).
check_term(integer, 0).
check_term(var + integer, A).
check_term(var + integer, 0).
```
*/
check_term(var, A) :- var(A), !.
check_term(integer, A) :- integer(A), !.
check_term(atom, A) :- atom(A), !.
check_term(string, A) :- string(A), !.
check_term(nonvar, A) :- nonvar(A), !.
check_term(ground, A) :- ground(A), !.
check_term(Sum, A) :- nonvar(Sum), Sum = T + U, !, (check_term(T,A); check_term(U,A)).