sophia/test/contracts/functions.aes
2019-06-28 09:42:28 +02:00

16 lines
499 B
Plaintext

contract Functions =
function curry(f : ('a, 'b) => 'c) =
(x) => (y) => f(x, y)
function map(f : 'a => 'b, xs : list('a)) =
switch(xs)
[] => []
x :: xs => f(x) :: map(f, xs)
function map'() = map
function plus(x, y) = x + y
entrypoint test1(xs : list(int)) = map(curry(plus)(5), xs)
entrypoint test2(xs : list(int)) = map'()(((x) => (y) => ((x, y) => x + y)(x, y))(100), xs)
entrypoint test3(xs : list(int)) =
let m(f, xs) = map(f, xs)
m((x) => x + 1, xs)