funcons-simple-0.1.0.3: tests/Kdiverse/Kdiverse2.fct
initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope
(collateral (bind
("factorial",
allocate-variable (functions
(tuples ((values)*),
values))),
bind
("main",
allocate-variable (functions
(tuples ((values)*),
values)))),
sequential (assign
(bound ("factorial"),
function closure (scope
(match
(given,
tuple (pattern closure (bind
("y",
allocate-initialised-variable
(values,
given))))),
handle-return (sequential
(print ("Factorial of ",
assigned (bound ("y")),
" is: "),
scope
(bind
("t",
allocate-initialised-variable
(values,
decimal-natural ("1"))),
sequential
(scope
(bind
("i",
allocate-initialised-variable
(values,
decimal-natural ("1"))),
while
(is-less-or-equal
(assigned (bound ("i")),
assigned (bound ("y"))),
sequential
(effect (give
(integer-multiply
(assigned (bound ("t")),
assigned (bound ("i"))),
sequential
(assign
(bound ("t"),
given),
given))),
effect (give
(bound ("i"),
sequential
(assign
(given,
integer-add
(assigned (given),
1)),
assigned (given))))))),
return (assigned (bound ("t")))))))))),
assign
(bound ("main"),
function closure (scope
(match
(given,
tuple ()),
handle-return (sequential
(print ("Input a natural number: "),
print (apply
(assigned (bound ("factorial")),
tuple (read)),
"\n")))))),
apply
(assigned (bound ("main")),
tuple ())))