object
optional(Optional)
Optional term handling predicates. Requires passing an optional term (constructed using the optional object predicates) as a parameter.
static, context_switching_callsPublic predicates
is_empty/0
True if the optional term is empty. See also the if_empty/1 predicate.
staticis_empty - zero_or_oneis_present/0
True if the optional term holds a value. See also the if_present/1 predicate.
staticis_present - zero_or_oneif_empty/1
Calls a goal if the optional term is empty. Succeeds otherwise.
staticif_empty(Goal)if_empty(0)if_empty(+callable) - zero_or_moreif_present/1
Applies a closure to the value hold by the optional term if not empty. Succeeds otherwise.
staticif_present(Closure)if_present(1)if_present(+callable) - zero_or_moreif_present_or_else/2
Applies a closure to the value hold by the optional term if not empty. Otherwise calls the given goal.
staticif_present_or_else(Closure,Goal)if_present_or_else(1,0)if_present_or_else(+callable,+callable) - zero_or_morefilter/2
Returns the optional term when it is not empty and the value it holds satisfies a closure. Otherwise returns an empty optional term.
staticfilter(Closure,NewOptional)filter(1,*)filter(+callable,--nonvar) - onemap/2
When the optional term is not empty and mapping a closure with the value it holds and the new value as additional arguments is successful, returns an optional term with the new value. Otherwise returns an empty optional term.
staticmap(Closure,NewOptional)map(2,*)map(+callable,--nonvar) - oneflat_map/2
When the optional term is not empty and mapping a closure with the value it holds and the new optional term as additional arguments is successful, returns the new optional term. Otherwise returns an empty optional term.
staticflat_map(Closure,NewOptional)flat_map(2,*)flat_map(+callable,--nonvar) - oneor/2
Returns the same optional term if not empty. Otherwise calls closure to generate a new optional term. Fails if optional term is empty and calling the closure fails or throws an error.
staticor(NewOptional,Closure)or(*,1)or(--term,@callable) - zero_or_oneget/1
Returns the value hold by the optional term if not empty. Throws an error otherwise.
staticget(Value)get(--term) - one_or_errorexistence_error(optional_term,Optional)or_else/2
Returns the value hold by the optional term if not empty or the given default value if the optional term is empty.
staticor_else(Value,Default)or_else(--term,@term) - oneor_else_get/2
Returns the value hold by the optional term if not empty. Applies a closure to compute the value otherwise. Throws an error when the optional term is empty and the value cannot be computed.
staticor_else_get(Value,Closure)or_else_get(*,1)or_else_get(--term,+callable) - one_or_errorexistence_error(optional_term,Optional)or_else_call/2
Returns the value hold by the optional term if not empty or calls a goal deterministically if the optional term is empty.
staticor_else_call(Value,Goal)or_else_call(*,0)or_else_call(--term,+callable) - zero_or_oneor_else_fail/1
Returns the value hold by the optional term if not empty. Fails otherwise. Usually called to skip over empty optional terms.
staticor_else_fail(Value)or_else_fail(--term) - zero_or_oneor_else_throw/2
Returns the value hold by the optional term if not empty. Throws the given error otherwise.
staticor_else_throw(Value,Error)or_else_throw(--term,@nonvar) - one_or_errorProtected predicates
(none)
Private predicates
(none)
Operators
(none)
See also