What is an easy way to delete elements from the list which are >5.
I have this solution:
delete_element(_,,).
delete_element(E,[E|R],RL) :-
delete_element(E,R,RL).
delete_element(E,[X|R],[X|RL]) :-
X=E, delete_element(E,R,RL).
The way you’ve written the predicate only checks the first element, because you ask that E unify with each element in the list, but that unification can only succeed for the first entry, because the numbers are different.
I think the easiest way to do this would be to pass a goal that determines which elements to include or remove, like exclude/3
e.g.