*
Aren't we all bored of NN is N+1? Why go through all this hassle?
Good news everyone: this module allows you to release your inner god of chaos
and use destructive assignment - in PROLOG!
Of course, everything comes with a price; if you thought that
=/2 vs ==/2 vs =':='/2 vs is/2 is confusing then you might want to run...
- author
- - Thanos Tintinidis <thanosqr@gmail.com>
- version
- - 1.0
- See also
- - http://en.wikipedia.org/wiki/Alignment_%28Dungeons_%26_Dragons%29#Chaotic_Evil
- deprecated
- -
- license
- - This program is free software. It comes without any warranty,
to the extent permitted by applicable law. You can
redistribute it and/or modify it under the terms of the Do
What The Fuck You Want To Public License, Version 2, as
published by Sam Hocevar. See the file COPYING in the project
root directory or consult http://www.wtfpl.net/txt/copying for
more details.
- To be done
- - Destructive assignments can never stop; therefore, this module
is eternally in a state of flux
- defvar(Var:term) is det
- Since we are abandoning our high-level discipline, why not start declaring
our variables? defvar/1 allows you to declare one empty d-variable (but most
of the times it is pointless). Nevertheless, it demonstrates the basic
structure of our variables:
v(_value)
(where v stands for eVil and Variable)
?- defvar X.
X = v(_G666).
- X:var := Y:var is det
- ':='/2 will assign the value Y to X. If Y contains instances of X, they
will be replaced by its value to avoid cyclic terms Note that X can be a
d-variable (empty or not) or a non-instantiated variable.
?- X := 42.
X = v(42).
?- X := 42, print(X), X := 17, print(X).
4217
X = v(17).
?- defvar(X), X := 42.
X = v(42).
?-X:=1+1.
X = v(1+1)
?- X:=1, X:=X+1.
X = v(1+1)
?- X:=1, X := X+1+v(2)+v(3+v(32)).
X = v(1+1+v(2)+v(3+v(32))).
- See also
- - ':=:'/2
- :=:(X:var, Y:term) is det
- ':=:'/2 behaves similarly to ':='/2 but evaluates the expression Y before
assigning it to X.
?- X :=: 1.
X = v(1).
?- X :=: 1+1.
X = v(2).
?- X := 1+1.
X = v(1+1).
?- X:=1, X :=: X+1.
X = v(2).
?- X:=1, X :=: X+1+v(2)+v(3+v(32)).
X = v(39).
- See also
- - ':='/2
- iss(Y:var, X:term) is det
- iss/2 evaluates the expression X and assigns (non-destructively) the value
to Y.
?- Y iss 1+v(2)+v(3+v(32)).
Y = 38.
?- v(Y) iss 1+v(2)+v(3+v(32)).
false.
- ++(X:var) is semidet
- Adds one to the value of a d-variable. If the d-variable is empty, an
exception will be thrown.
Usage (covering ++/1, --/1, -:-/1, and +:+/1):
?- X := 1, X++ .
X = v(1+1).
?- X := 1, ++X .
X = v(1+1).
?- X := 1, +:+X.
X = v(2).
?- X := 1, X++, X++ .
X = v(1+1+1).
?- X := 1, X++, X++, +:+X.
X = v(4).
- See also
- - +:+/1
- - --/1
- - -:-/1
- +:+(X:var) is semidet
- Adds one to the value of a d-variable after evaluating it. If the
d-variable is empty, an exception will be thrown.
- See also
- - --/1
- - +:+/1
- - -:-/1
- --(X:var) is semidet
- Subtracts one from the value of a d-variable. If the d-variable is empty,
an exception will be thrown.
- See also
- - ++/1
- - +:+/1
- - -:-/1
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- -:-(Arg1)
- -:-(Arg1)