[m-users.] Anonymous recursive functions/predicates

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Aug 20 16:03:31 AEST 2021



On Fri, 20 Aug 2021 07:50:45 +0200, "Mark Clements (gmail)" <samuel.legotus at gmail.com> wrote:

> Is there any 
> way to declare or use an anonymous recursive function in Mercury?

No, there is not. Mercury's mode system does not allow a variable
to be defined in terms of itself, which is why this code ...

>      Loop = (func(I, Y) = (if I>Finish then Y
>                            else Loop(I+1, if Predicate(I)=yes then Y+1 else Y)))

... gets the error you reported.

Zoltan.



More information about the users mailing list