Search code examples
linked-listelm

Removing an element from a list in Elm


Basically what I want to do is something like ...

removefromList "A" ["A", "B", "A"] and get back a new list of ["B"]

Does anyone know how to do this?

Thank you!


Solution

  • List.filter provides a way to make a new list based on an input list, filtering out elements that don't match the predicate.

    List.filter (\x -> x /= "A") ["A", "B", "A"]
    -- yields: ["B"]