[m-users.] Generic predicate for enumeration types
Philippe de Rochambeau
phiroc at free.fr
Fri May 14 21:22:05 AEST 2021
Hello,
I would like to create a predicate called small which works for the cat and dog types show below.
I’ve tried to create a generic predicate, but to no avail:
:- pred cat(T::out) is multi.
cat(X) :- small(X).
Any help would be much appreciated.
Many thanks.
Philippe
-----------------------------------------------------------------------------------
:- implementation.
:- type cat
---> bill
; harry
; mary
; steve.
:- type dog
---> fido
; fred
; henry
; jane
; rover
; tom.
:- pred cat(cat::out) is multi.
cat(Cat) :- small(Cat).
:- pred dog(dog::out) is multi.
dog(Dog) :- small(Dog).
:- pred small(cat).
:- mode small(in) is semidet.
:- mode small(out) is multi.
small(steve).
small(harry).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210514/34665127/attachment.html>
More information about the users
mailing list