[mercury-users] Switch detection question

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Wed May 22 06:52:35 AEST 2002


Hi.

  How can I write a code like this:

:- module clip.
:- implementation.
:- import_module int.

:- pred bar(int::in, int::out) is semidet.

bar(X, Y) :-
  X = 5,
    Y = 2;
  (X = 3; X = 4),
    Y = 7
  .

  ...without confusing the switch detection algorithm?

clip.m:  1: Warning: interface for module `clip' does not export anything.
clip.m:005: In `bar(in, out)':
clip.m:005:   error: determinism declaration not satisfied.
clip.m:005:   Declared `semidet', inferred `nondet'.
clip.m:009:   Disjunction has multiple clauses with solutions.


  I prefer not to hear about if-then-else decistion tree or explicit
enumeration of all the possible values:

bar(X, Y) :-
  X = 5,
    Y = 2;
  X = 3,
    Y = 7;
  X = 4,
    Y = 7
  .


  Thanks, Andrew.

P.S.: I will never stop using Mercury. Even if it can't detect deeper
switches! :-)

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list