I am trying to get a feel for Prolog programming by going through Ulle Endriss\' lecture notes. When my solution to an exercise does not behave as expected, I find it diffi
this code would work:
last1([Last], Last). last1([_ | Rest], Last) :- last1(Rest, Last), !.
it is because prolog things there might be more combinations but, with this symbol: !, prolog won't go back after reaching this point