[mercury-users] How do you call a semidet constant function?

Mark Brown mark at cs.mu.OZ.AU
Fri Mar 10 03:44:16 AEDT 2006


Hi Ian,

On 10-Mar-2006, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> Hello,
> 
> I'm trying to implement a function like the following:
> 
> :- func default_value(((func) = T)::in((func) = out is semidet), T::in)
> 	= (T::out) is det.
> 
> default_value(F, X) =
>         ( if F = Y then
>                 Y
>         else
>                 X
>         ).
> 
> How do I convince the compiler to unify Y with the result of F and not
> the function F?

Use apply(F).

Cheers,
Mark.

--------------------------------------------------------------------------
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