I have a list I need to find an element and remove it.
The idea I'm going on is to remove it if it's the head and join that with removing it if it's the head of the tail. I have no idea how to do that though.
Any advice is appreciated.
This is what I've got
choice(8, X):-
nl, write('\tRemove a student from roster:'),nl,nl,
write('\tEnter student name or ID : '), read(S), remove(S, X, X2), nl, menu(X2).
remove(S, [], []):- write('\tStudent '), writef("%s", [S]), write(' is not in the roster.'),nl.
remove(S, [[I,N,G]|T], X):-
S = I -> X = T2, remove(S, T, T2);
T = [] -> X = [];
X = [[I,N,G]|T2], remove(S, T, T2).
I want it to remove all occurrences.