What is the difference in execution if the cut '!' is present?
问题 counter([],[]). counter([H|T],[[H,C1]|R]) :- counter(T,[[H,C]|R]),!, C1 is C+1. counter([H|T],[[H,1]|R]) :- counter(T,R). What is the effect of the "!" as I'm getting the same output for an input in both the above and below code? counter([],[]). counter([H|T],[[H,C1]|R]) :- counter(T,[[H,C]|R]),C1 is C+1. counter([H|T],[[H,1]|R]) :- counter(T,R). I'm new to Prolog. 回答1: What is the effect of the "!" The cut prunes the search space. That is, in an otherwise pure and monotonic program, the cut