1Array.zipWith(3kaya) Kaya module reference Array.zipWith(3kaya)
2
3
4
6 Array::zipWith - Map a function across two arrays.
7
9 [c] zipWith( c(a, b) f, [a] xs, [b] ys )
10
12 f The function to use
13
14 xs The first array
15
16 ys The second array
17
19 Returns the array created by applying function f to every pairwise ele‐
20 ments of xs and ys
21 If the arrays are of different lengths, then the resulting array will
22 be the same size as the shorter of the two input arrays.
23
24 The function must take xs[0] and ys[0] to give zs[0] and so on.
25
26
27 Int sum(Int a, Int b) {
28 return a+b;
29 }
30
31 Void main() {
32 xs = [1,2,3,4,5];
33 ys = [7,8,9];
34 zs = zipWith(sum,xs,ys);
35 // zs = [8,10,12];
36 }
37
39 Kaya standard library by Edwin Brady, Chris Morris and others
40 (kaya@kayalang.org). For further information see http://kayalang.org/
41
43 The Kaya standard library is free software; you can redistribute it
44 and/or modify it under the terms of the GNU Lesser General Public
45 License (version 2.1 or any later version) as published by the Free
46 Software Foundation.
47
49 Array.map (3kaya)
50 Array.zip (3kaya)
51
52
53
54Kaya December 2010 Array.zipWith(3kaya)