Defined¶
&df{x}
This atom may be used in the body to reason about whether a given variable x is defined or not. This is useful for instance to provide defaults or detect errors if a certain integer variable does not have a value but should.
Example
For instance, take program
price(frame,15).
default_price(20).
selected(frame).
{ selected(bag) }.
&sus{V} = price(P) :- selected(P), price(P,V).
&sus{price(P) : selected(P)} =: calc_price(total).
&sus{price(total)} = calc_price(total) :- &df{calc_price(total)}.
&sus{price(total)} = D :- not &df{calc_price(total)},
default_price(D).
#show selected/1.
&show{price/1}.
Calling
flingo examples/config_default_in.lp 0
Answer: 1
selected(frame) selected(bag) val(price(frame),15) val(price(total),20)
Answer: 2
selected(frame) val(price(frame),15) val(price(total),15)