declare(Variable, Value)
Binds a value to a variable globally when called
Arguments:
- Variable - atomic name of variable
- Value - value to be bound
Example - Bind 5 to a variable with label "a":
?- declare(a, 5).
true.
display_bindings
Displays all current bindings
Example - declare variables "a" and "b" and display:
?- declare(a, 5).
true.
?- declare(b, 7).
true.
?- display_bindings.
a -> 5
b -> 7
true.
value_of(Variable, Value)
Gets a value from a global variable
Arguments:
- Variable - atomic name of variable
- Value - value bound to variable
Example - Get value of variable "a":
?- declare(a, 5).
true.
?- value_of(a, Value).
Value = 5.
bind(Variable, Value)
Rebinds a value to a global variable
Arguments:
- Variable - atomic name of pre-existing variable
- Value - value bound to variable
Example - Rebind 7 to variable "a" :
?- declare(a, 5).
true.
?- bind(a, 7).
true.
undeclare(Variable)
Deletes a global variable
Arguments:
- Variable - atomic name of pre-existing variable
Example - delete variable "a" :
?- declare(a, 5).
true.
?- undeclare(a).
true.
?- display_bindings.
true.
inc(Variable)
Increments a global variable
Arguments:
- Variable - atomic name of pre-existing variable
Example - increment variable "a" :
?- declare(a, 5).
true.
?- display_bindings.
a -> 5
true.
?- inc(a).
true.
?- display_bindings.
a -> 6
true.
dec(Variable)
Decrements a global variable
Arguments:
- Variable - atomic name of pre-existing variable
Example - decrement variable "a" :
?- declare(a, 5).
true.
?- display_bindings.
a -> 5
true.
?- dec(a).
true.
?- display_bindings.
a -> 4
true.
add(Variable, Value)
Adds to a global variable
Arguments:
- Variable - atomic name of pre-existing variable
- Value - value to add
Example - add 3 to variable "a" :
?- declare(a, 5).
true.
?- display_bindings.
a -> 5
true.
?- add(a,3).
true.
?- display_bindings.
a -> 8
true.
sub(Variable, Value)
Subtracts from a global variable
Arguments:
- Variable - atomic name of pre-existing variable
- Value - value to subtract
Example - subtract 3 from variable "a" :
?- declare(a, 5).
true.
?- display_bindings.
a -> 5
true.
?- sub(a,3).
true.
?- display_bindings.
a -> 2
true.