sophia/test/contracts/polymorphism_test.aes
2018-12-22 01:23:40 +01:00

17 lines
379 B
Plaintext

contract Identity =
function zip_with(f, xs, ys) =
switch((xs, ys))
(x :: xs, y :: ys) => f(x, y) :: zip_with(f, xs, ys)
_ => []
// Check that we can use zip_with at different types
function foo() =
zip_with((x, y) => x + y, [1, 2, 3], [4, 5, 6, 7])
function bar() =
zip_with((x, y) => if(x) y else 0, [true, false, true, false], [1, 2, 3])