2019-09-21 14:59:48 -07:00
|
|
|
// Test a PascaLIGO function which takes another PascaLIGO function as an argument
|
2019-05-12 20:56:22 +00:00
|
|
|
function foobar (const i : int) : int is
|
|
|
|
function foo (const i : int) : int is
|
|
|
|
block { skip } with i ;
|
|
|
|
function bar (const f : int -> int) : int is
|
|
|
|
block { skip } with f ( i ) ;
|
|
|
|
block { skip } with bar (foo) ;
|
2019-09-27 17:31:38 +02:00
|
|
|
|
|
|
|
// higher order function with more than one argument
|
|
|
|
function higher2(const i: int; const f: int -> int): int is
|
2019-10-17 17:33:29 +02:00
|
|
|
block {
|
|
|
|
const ii: int = f(i)
|
|
|
|
} with ii
|
2019-09-27 17:31:38 +02:00
|
|
|
|
|
|
|
function foobar2 (const i : int) : int is
|
|
|
|
function foo2 (const i : int) : int is
|
|
|
|
block { skip } with i;
|
2019-10-02 17:28:11 +02:00
|
|
|
block { skip } with higher2(i,foo2)
|
|
|
|
|
2019-10-17 17:18:10 +02:00
|
|
|
const a : int = 0;
|
|
|
|
function foobar3 (const i : int) : int is
|
|
|
|
function foo2 (const i : int) : int is
|
|
|
|
block { skip } with (a+i);
|
|
|
|
block { skip } with higher2(i,foo2)
|
2019-10-03 15:36:06 +02:00
|
|
|
|
|
|
|
function f (const i : int) : int is
|
|
|
|
block { skip }
|
|
|
|
with i
|
|
|
|
|
|
|
|
function g (const i : int) : int is
|
|
|
|
block { skip }
|
|
|
|
with f(i)
|
|
|
|
|
|
|
|
function foobar4 (const i : int) : int is
|
|
|
|
block { skip }
|
|
|
|
with g(g(i))
|
2019-10-17 17:33:29 +02:00
|
|
|
|
|
|
|
function higher3(const i: int; const f: int -> int; const g: int -> int): int is
|
|
|
|
block {
|
|
|
|
const ii: int = f(g(i));
|
|
|
|
} with ii
|
|
|
|
|
|
|
|
function foobar5 (const i : int) : int is
|
|
|
|
const a : int = 0;
|
|
|
|
function foo (const i : int) : int is
|
|
|
|
block { skip } with (a+i);
|
|
|
|
function goo (const i : int) : int is
|
|
|
|
block { skip } with foo(i);
|
|
|
|
block { skip } with higher3(i,foo,goo)
|