Algosim documentation: RemoveAll

RemoveAll

Removes every occurrence of a given value from a container.

Syntax

Description

If X is a linear container and x any object, then RemoveAll(X, x) returns X with every instance of x removed. RemoveAll(X, x, n) removes elements from level n.

Examples

v ≔ RandomIntVector(20, −3, 4)
(1, −3, −3, 0, −3, 3, 0, 0, −1, −2, 2, 0, 2, 3, −1, 2, 2, 2, 3, −2)
RemoveAll(v, 0)
(1, −3, −3, −3, 3, −1, −2, 2, 2, 3, −1, 2, 2, 2, 3, −2)
compute(RandomIntVector(20, −3, 4), n, 1, 5)
(−1, −3, −2, −1, 0, −2, 3, −2, 2, 3, 0, −3, −3, 1, 2, 1, 0, 2, 2, −2)
(3, −1, 3, 3, −1, 2, 1, 2, 1, 1, 1, 3, 0, 3, 2, −3, −1, −1, 0, 2)
(−1, 3, −1, 1, 1, 1, 3, 1, 2, 2, 2, 1, −3, 1, −2, −3, −1, 0, 0, −3)
(0, 2, −2, −3, −3, −2, 1, 0, −3, −3, 2, −3, 2, −3, −2, −2, 3, 0, −2, −2)
(−3, −2, −3, −1, 3, −2, 0, −3, −3, 3, 1, 2, 1, −2, −2, −2, 0, 2, 1, −2)
RemoveAll(ans, 0, 2)
(−1, −3, −2, −1, −2, 3, −2, 2, 3, −3, −3, 1, 2, 1, 2, 2, −2)
(3, −1, 3, 3, −1, 2, 1, 2, 1, 1, 1, 3, 3, 2, −3, −1, −1, 2)
(−1, 3, −1, 1, 1, 1, 3, 1, 2, 2, 2, 1, −3, 1, −2, −3, −1, −3)
(2, −2, −3, −3, −2, 1, −3, −3, 2, −3, 2, −3, −2, −2, 3, −2, −2)
(−3, −2, −3, −1, 3, −2, −3, −3, 3, 1, 2, 1, −2, −2, −2, 2, 1, −2)

See also