Removes all occurrences of an element from a list.
remove(xs:list, x:any) -> list
Description
Section titled “Description”The remove
function returns the list xs
with all occurrences of x
removed.
If x
is not present in the list, the original list is returned unchanged.
xs: list
Section titled “xs: list”A list to remove elements from.
x: any
Section titled “x: any”The value to remove from the list.
Examples
Section titled “Examples”Remove an element from a list
Section titled “Remove an element from a list”from {xs: [1, 2, 3, 2, 4]}xs = xs.remove(2)
{xs: [1, 3, 4]}
Remove a non-existent element
Section titled “Remove a non-existent element”from {xs: [1, 2, 3]}xs = xs.remove(5)
{xs: [1, 2, 3]}
Remove from a list with strings
Section titled “Remove from a list with strings”from {xs: ["apple", "banana", "apple", "orange"]}xs = xs.remove("apple")
{xs: ["banana", "orange"]}