Skip to content

remove

Removes all occurrences of an element from a list.

remove(xs:list, x:any) -> list

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.

A list to remove elements from.

The value to remove from the list.

from {xs: [1, 2, 3, 2, 4]}
xs = xs.remove(2)
{xs: [1, 3, 4]}
from {xs: [1, 2, 3]}
xs = xs.remove(5)
{xs: [1, 2, 3]}
from {xs: ["apple", "banana", "apple", "orange"]}
xs = xs.remove("apple")
{xs: ["banana", "orange"]}

add, append, prepend distinct

Last updated: