object
optional(Optional)
Optional term handling predicates. Requires passing an optional term (constructed using the optional object predicates) as a parameter.
logtalk_load(optionals(loader))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_errormap_or_else/3
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 the new value. Otherwise returns the given default value.
staticmap_or_else(Closure,Default,Value)map_or_else(2,*,*)map_or_else(+callable,@term,--term) - onezip/3
When both this optional and the other optional hold values and applying a closure with both values and the new value as additional arguments is successful, returns an optional term with the new value. Otherwise returns an empty optional term.
staticzip(Closure,OtherOptional,NewOptional)zip(3,*,*)zip(+callable,+nonvar,--nonvar) - oneflatten/1
Flattens a nested optional term. When the optional term holds a value that is itself an optional term, returns the inner optional term. When the optional term holds a non-optional value, returns the same optional term. When the optional term is empty, returns an empty optional term.
staticflatten(NewOptional)flatten(--nonvar) - oneto_expected/2
Converts the optional term to an expected term. Returns an expected term holding the value if the optional term is not empty. Returns an expected term with the given error otherwise.
staticto_expected(Error,Expected)to_expected(@term,--nonvar) - oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)
See also