Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 683
Carter Weinberg Avatar asked Sep 06 '25 03:09

Carter Weinberg


1 Answers

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"]
like image 147
Chad Gilbert Avatar answered Sep 07 '25 22:09

Chad Gilbert