[mercury-users] Disjunctions vs. multiple head clauses

Peter Hawkins peter at hawkins.emu.id.au
Wed Apr 7 12:09:14 AEST 2004


Hi...

Is there any difference in efficiency between the two predicates bar1 and bar2 
in the following? In Prolog there would (usually) be, but does the same apply 
to Mercury?

:- type foo ---> fa ; fb ; fc ; fd ; ... ; fz.

:- pred bar1(foo, int).
:- mode bar1(in, out) is det.

bar1(fa, 1).
bar1(fb, 2).
bar1(fc, 3).
...
bar1(fz, 26).

:- pred bar2(foo, int).
:- mode bar2(in, out) is det.

bar2(F, N) :-
	(F = fa, N = 1
	; F = fb, N = 2
	; ...
	; F = fz, N = 26
	).

(obviously the actual code I'm interested in would be more complex than this 
toy example)

Thanks,
Peter
--------------------------------------------------------------------------
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