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.