[m-users.] (P ; not P)
Julian Fondren
jfondren at minimaltype.com
Tue Sep 10 16:26:15 AEST 2019
Hello list,
Mercury infers that the following is nondet:
:- func fizzbuzz(int) = string.
fizzbuzz(N) = R :-
(
fizz(N), buzz(N), R = "FizzBuzz"
;
fizz(N), not buzz(N), R = "Fizz"
;
not fizz(N), buzz(N), R = "Buzz"
;
not fizz(N), not buzz(N), R = string.from_int(N)
).
Where fizz/1 and buzz/1 are just semidet predicates:
:- pred fizz(int::in) is semidet.
:- pred buzz(int::in) is semidet.
Is there a right way to do a disjunction over semidet predicates like
this, or is turning them into the bools the best you can do if you
want a disjunction over all the cases?
( if fizz(N) then Fizz = yes else Fizz = no ),
( if buzz(N) then Buzz = yes else Buzz = no ),
(
Fizz = yes, Buzz = yes, R = "FizzBuzz"
;
...
)
More information about the users
mailing list