let
var z := 5
var u := "I love compiling!\n"
function f(x:int, y:int) : int = x+y-1
function factorial(n:int) : int =
if n<2 then n else n*factorial(n-1)
function tailfact(n:int, m:int) : int =
if n<2 then m
else tailfact(n-1,m*n)
function ifact(n:int) : int =
let var ax := 1
var ln := n % locals can't be changed in bobcat
in
while ln>1
do
( ax := ax*ln;
ln := ln-1
);
ax
end % ifact
in
while z>1
do (
z := z-1;
printf("n = %d\n",z)
);
z := f(4,z+2);
printf("z is finally %d\n",z);
if z>10 then printf("z is big\n")
else if z>2 then printf("z is small\n")
else printf("z is tiny\n");
z := factorial(6);
printf("the factorial of 6 is %d\n",z);
printf("with tail recursion it's also %d\n",tailfact(6,1));
printf("without recursion it's still %d\n",ifact(6));
printf(u)
end
$