Ello, ive got the Prolog function member which tells us if an element exists in a list.
now i should create a function that returns a list without that element. i know more or less how it should look like, but somehow i have no idea how to do it.
ideas so far:
- return the elements in the list before our element, and concat it with the rest of the list after our element.
- use member() in a predicate that goes through the list recursively and builds it.
help.
(Seems like homework to me so I’ll give you an outline containing some hints 😉
Given
[H|T]…His the element to remove, returnT, (If you need to remove all such elements, remember to recurse onTas well.)His not the element to remove, return[H|NewTail]whereNewTailis result of recursively removing the element fromT.