Is there any reason why, upon failing the first predicate, not to try the second function?
Although my code is more complicated, I will not show it because it is a homework. I just want to know if there would be any reason why upon returning false from the first predicate, the program doesnāt redo the function, but with the second predicate.
Note: The pattern matching stuff is not the problem. I am 100% sure my function matches at least one pattern written after the predicate which fails.
Call:odd_number(6)
Call:not(even(6))
Fail:not('10892dd7-de05-49c0-8057-1d7684c4ae68' : even(6))
*Calls some weird function completely unrelated to this predicate*
Please explain what you are doing and why? Like, why are you using write? Why does odd have two clauses? Why?
But to answer your question, to me it looks very much like there is a REDO and the second clause of odd_number/1 is executed. The output is right there, it says ā6ā on a line of its own, right?
PS: āI am not allowed to show you the codeā makes this very difficult.
My problem is that if not(some_condition) returns false, the program never goes to the second predicate (i.e doesnāt write āa condition returned falseā).
Weirdly enough, if condition returns false, the program goes to the second predicate. This is really strange. Also, this proves it has nothing to do with pattern matching, but it has something to do with not(some_condition) in particular.
Iām sorry, Iām just not allowed to show any code since it is an assignment, so I canāt copy-paste the actual code. I just wanted an idea why behaviour like that would be exhibited by a Prolog predicate. The odd_number code works perfectly, I just wanted to offer an insight into what structure my code has. Iāll give you the āSolutionā because you tried to understand - however, I still canāt reproduce any example of my code and am not allowed to copy-paste my code.