This is a very basic question, but I don’t understand why I can’t just rermove the write() and add another item in the list I pass into the format() function.
?- get_cust_bal_1(F,L).
tom smith owes us $20.55
F = tom,
L = smith ;
sally smith owes us $120.55
F = sally,
L = smith.
?- get_cust_bal(F,L).
tom smith owes us $20.55
F = tom,
L = smith ;
sally smith owes us $120.55
F = sally,
L = smith.
I did rename the first predicate to make it different from the second and did press space bar to see additional answers but it does work without errors.
This was done using SWI-Prolog (threaded, 64 bits, version 8.3.0-172-g5e86d749d) on Window 10.
This is a daily build which is why the version number my not look correct but it is correct.
I know that the code you posted works. That wasn’t the question. The question was why I can’t remove the write() without causing an error. My actual code is the final snippet. The code that works is the first snippet. I want to know why removing the write() in my code breaks it.
Can you share the complete file? Please remove all the irrelevant stuff, but make sure the bug remains. At least the location than fits and may give a hint. My suspicion is there is something unreadable in the file like a zero-space character or whatever.
I did look at that, but the only thing that appears to even remotely comment it out (shows everything in the same colour as it would be if it were a comment) is the # symbol.
EDIT: Multiline JavaDoc comments seem to work, but single-line (%) comments don’t.
Are you saying your editor is complaining about the % as a comment? If so and Prolog is running the code correctly then it is your editor that is the problem. If it is Prolog complaining when the code is run the we should see why. In the many years of using SWI-Prolog I have never seen it complain about a % comment. I have seen them used in the wrong place and cause syntax errors.
I’m also using VS Code, and it isn’t complaining about the percent sign, but it doesn’t colour that line all in the same colour as it does in other languages. Do you also have this? Is there a setting I need to change?