1:- module(
2 default,
3 [
4 call_default_value/2, % ?Value, :Goal_1
5 call_default_value/3, % ?Value, :Goal_1, +DefaultValue
6 default_value/2, % ?Value, +DefaultValue
7 default_value/3 % ?FromValue, -ToValue, +DefaultValue
8 ]
9).
15:- meta_predicate
16 call_default_value( , ),
17 call_default_value( , , ).
28call_default_value(Value, _) :- 29 nonvar(Value), !. 30call_default_value(Value, Goal_1) :- 31 call(Goal_1, Value).
39call_default_value(Value, Goal_1, _) :- 40 call(Goal_1, Value), !. 41call_default_value(DefaultValue, _, DefaultValue).
Ordering is a meta-argument that allows a list of elements to be arbitrarily ordered. The use of default_value/2 here allows the original ordering of elements to be retained in case the Ordering argument is not instantiated.
default_value(=, Ordering), once(call(Ordering, L1, L2))
62default_value(Value, _):- 63 nonvar(Value), !. 64default_value(DefaultValue, DefaultValue).
@note We are sometimes using this predicate instead of
default_value/2 from `library(default)
' because we do not want
variable occurrences of `FromValue' to get instantiated.
77default_value(X, Y, Y):- 78 var(X), !. 79default_value(X, X, _)
Support for default values
*/