I have a complex program, a part of which looks somewhat like this:
check_list([]).
check_list([X|List]) :- (try_something(X) -> write(1);write(0)),nl,check_list(List).
The problem is that, when my list gets very large, Prolog gives me "Resource error: insufficient memory". I thought the problem might be somewhere in the if-then-clause. So I tried the following:
check_list([]).
check_list([X|List]) :- (\+try_something(X) -> write(0);write(1)),nl,check_list(List).
With that, the problem is gone (or at least it only appears with much much bigger lists). However, I have no clue why. What is so different in the two versions? Shouldn't both be the same?