add parameters to functions

This commit is contained in:
Peter
2023-12-13 15:27:55 +01:00
parent c4f9bbcbfa
commit c7bf88c33a
9 changed files with 190 additions and 41 deletions

View File

@@ -1,28 +1,65 @@
initialise-binding scope
(collateral
(bind
("a",
allocate-variable
(integers)),
bind
("test",
function abstraction
(scope
(collateral
(map
( )),
return decimal-natural
("3")))),
( ),
bind
("a",
allocate-initialised-variable
(integers,
checked head
given)),
give
(checked tail
given,
bind
("b",
allocate-initialised-variable
(integers,
checked head
given)))),
return int-mul
(assigned
(bound
("a")),
assigned
(bound
("b")))))),
bind
("x",
allocate-initialised-variable
(integers,
0)),
("b",
allocate-variable
(integers)),
map
( ),
map
( )),
sequential
(null,
(assign
(bound "a",
decimal-natural
("20")),
null,
assign
(bound "x",
(bound "b",
handle-return apply
(bound "test",
null)),
cons
(decimal-natural
("6"),
list
(decimal-natural
("3"))))),
print assigned
(bound
("x"))))
("a")),
print assigned
(bound
("b"))))

View File

@@ -1,9 +1,11 @@
int a =20;
fun test() {
return 3;
fun test(a, b) {
return a*b;
}
x = test();
int b =test(6, 3);
print(x);
print(a);
print(b);