[m-users.] Trying to understand a predicate for calculating Fibonacci numbers
Julien Fischer
jfischer at opturion.com
Thu Nov 9 11:35:46 AEDT 2017
On Thu, 9 Nov 2017, Tomas By wrote:
>> On November 9, 2017 at 12:15 AM zeldangit <zeldangit at gmail.com> wrote:
>> So I am trying to understand the following code. How is X = A + B searched
>> for? So A + B has to add up to X, which is passed to the function, but
>> there is no explanation of how Mercury discovers these variables that add
>> up to X.
>
> It's a bit difficult to understand exactly what you mean here. First I thought you were not familiar with recursion, but perhaps it is the difference between function and procedure that is not clear to you.
>
> A and B are output parameters of the procedure calls. Then X is calculated.
>
>
>> Also, should I read a Prolog book to have a better grasp of Mercury?
>
> It's probably the best way to learn it.
Peter Wang has been working on a tutorial on the wiki,
<https://github.com/Mercury-Language/mercury/wiki/Tutorial>
Julien.
More information about the users
mailing list