Hello, I have a small question. I need to make a predicate that counts from a natural number to some other natural number. I have to implement a check too, that the second interval is bigger than the first one. However I got stuck during my way.
Here is my code (SWI-PROLOG)
count(O, _, O). count(A, B, C) :- count(A, B, D), C is D+1, C =< B.
It works kind of well as, I can get the results C=1, C=2, C=3, C=4 if I type in count(1, 4, C). However I get stuck at the end, it will result in an error with stack overflow.
The question is how do I make it to stop? I have tried almost everything. =(
Thanks for your response!