Kaya 0.5.3 reference for Array::filter

List of functions and data types in Array

[a] filter(Bool(a) p, [a] xs)

Arguments

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];
}

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya