Algosim documentation: PickRecursive

PickRecursive

Returns a list of all nested elements that satisfy a given predicate.

Syntax

Description

If X is any container and p a predicate, then pick(X, p) returns the list of all nested elements x of X for which p(x) is true. This means that the result contains all elements of X for which p(x) is true as well as all elements of elements of X for which p(x) is true, and so on.

Examples

L ≔ '(1, 2, "dog", '(5, 2), '('(10, 52, 22, "cat", RandomMatrix(2)), π))
1
2
dog
(5, 2)
((10, 52, 22, cat, ((0.170356541174, 0.336530831177), (0.371417297749, 0.266364166513))), 3.14159265359)
PickRecursive(L, IsNumber)
1
2
5
2
10
52
22
0.170356541174
0.336530831177
0.371417297749
0.266364166513
3.14159265359

See also