filter
ABSTRACT
Given a vector, we spit out the subset of elements that matched the predicate. In particular, order is preserved across this transformation so that the returned vector is a subsequence of the input.
PARAMETERS
v | the vector that provides the elements that we want to filter |
predicate(x) | the predicate function that specifies which elements of the input vector should be kept in the output vector. The predicate should return 0 if the element should not be included, and any other number if it should be included. |
RETURN
a vector that is a subsequence of the input, and only contains the elements of the input vector that matched the predicated function
DECLARATION
func filter(v, predicate(x))