^open Num (* Wrap a string into a fixed-width block. *) let width = 54 let rec wrap puts s = if String.length s <= width then puts s else (puts (Str.string_before s width); puts "\n"; wrap puts (Str.string_after s width)) (* Staged implementation of power function. *) let is_zero = eq_num (Int 0) let square x = let z = x in z */ z let rec power n x = if is_zero n then Int 1 else if is_zero (mod_num n (Int 2)) then square(power (n//Int 2) x) else x */ (power (n -/ Int 1) x) ?> v | None -> "2" ?> =preamble(x'^"^"^y') (* Output begins here *) ?> =navbar("/power"^string_of_num y) ?>
The result is:
=postamble?>