projog

3.97. flag(X,Y,Z) - associates a key with a value.

The first argument must be an atom or structure. The name and arity of the first argument is used to construct the key. The second argument is the value currently associated with the key. If there is not currently a value associated with the key then it will default to 0. The third argument is the new value to associate with the key. The third argument must be a numeric value.

Examples

?- flag(p(a), X, 2).
X = 0

yes

?- flag(p(a), X, X*10).
X = 2

yes

?- flag(p(a), 2, 7).

no

?- flag(p(a), X, 5).
X = 20

yes

?- flag(p(b), 5, 7).

yes

?- flag(p, 1, 1).

no

?- flag(p, 0, 1).

yes

?- flag(a(a), X, 25).
X = 0

yes

?- flag(a(b), X, X+1).
X = 25

yes

?- flag(a(c), X, X+1).
X = 26

yes

?- flag(a(d), 26, 33).

no

?- flag(a(d), 27, 33).

yes