-- Factorial.russell
open integer in
open <*
fcn: safetype ~ func[val->val] ,
fcnl: safetype ~ func[fcn->fcn] ,
Y: func[ fcnl -> fcn ] ~
lambda F: fcnl in
lambda x:val in (F(Y F)) x ni
ni ,
Fact: fcnl ~
lambda fact: fcn in
lambda x:val in
if
(leq <a~x,b~1>)?t => 1
else => * <a~x, b~fact(- <a~x,b~1>)>
fi
ni
ni
*> in
(Y Fact) 12
ni
ni