I am trying to delete a specific element from a nested list.
delete(X,L,L1)
to delete all occurrences of X
from a list L
producing the list L1
. For exmaple:
?- delete(a,[a,b,[a,d],c],L1). will give us
[b,[d],c].
I am able to remove the element from a simple non nested list but can't figure out how to remove it in the inner list.
My code:
deletelist(Xs,[],Xs).
deletelist(Xs,[Y|Ys],Zs):- delete(Xs,Y,As),
deletelist(As,Ys,Zs).
Any help would be greatly appreciated