I am in the process of trying to create the fibonacci series using DCG in prolog. I have this for starters, however I have no idea why the code is not being carried out.
Here is the code below:
fib --> [0], [1].
fib --> [X, Y], {Z is X + Y}, [Z].
I get an error that the variables are not sufficiently instantiated. I know that this solution is far from the final one, however I am just struggling to comprehend why this is not possible. Any advice and input would be greatly appreciated!
Not efficient, but short:
Results in swi-prolog: