[a] filter(Bool(a) p, [a] xs)
Arguments
p: The predicate to test againstxs: The array to filter
Usage
Each element of xs is tested against the predicate p. The returned list contains those elements of xs for which the predicate is true. The predicate function may of course be partially applied for ease of programming.
Bool isDiv(Int d,Int a) {
return (a%d==0);
}
Void main() {
ints = [1,2,3,4,5,6,7,8];
odds = filter(isDiv@(3),ints);
// odds = [3,6];
}