| Did you know ... | Search Documentation: |
| Pack maybe -- prolog/maybe.pl |
just(_). Useful for include/3.nothing. Useful for exclude/3.nothing.just(Value); fails for nothing.call(Goal) succeeds, Maybe=just(Value), otherwise
Maybe=nothing. Goal typically binds Value. If Goal produces
multiple solutions on backtracking, so will call_maybe/3. In that
case, Maybe will never be nothing.
For example,
?- L = [a,b,c], call_maybe(L=[H|_], H, MaybeHead). H = a, MaybeHead = just(a). ?- L = [], call_maybe(L=[H|_], H, MaybeHead). MaybeHead = nothing.
Of course, that particular example could have been implemented with maybe_list/2 instead.
nothing. A non-empty list is equivalent to just(Head).nothing case.maplist(default_maybe_value(7), Maybes, DefaultedValues).
call(Goal, Value0, Value) succeeds for just values. Goal
is not called for nothing values, which remain unchanged. "Use the
source" for a clearer explanation.nothing leaves Accum0=Accum while just relates them via Goal.
"Use the source" for a clearer explanation.