Kaya 0.4.4 reference for Array::zipWith

List of functions and data types in Array

[c] zipWith(c(a, b) f, [a] xs, [b] ys)

Arguments

Usage

Returns the array created by applying function f to every pairwise elements of xs and ys. If the arrays are of different lengths, then the resulting array will be the same size as the shorter of the two input arrays.

The function must take xs[0] and ys[0] to give zs[0] and so on.

Int sum(Int a, Int b) {
    return a+b;
}

Void main() {
    xs = [1,2,3,4,5];
    ys = [7,8,9];
    zs = zipWith(sum,xs,ys);
// zs = [8,10,12];
}

Related

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