3 ms·
Well, what about this program?: -- factorial { {extern "manool.org.18/std/0.2/all"} in : let { Fact = { proc { N } as : unles
by rusini 7y ago
Well, what about this program?:
-- factorial
{ {extern "manool.org.18/std/0.2/all"} in
: let
{ Fact =
{ proc { N } as
: unless N.IsI48[] & (N >= 1 - 1) signal
{if (~)[N.IsI48[]] then TypeMismatch else InvariantViolation}
else
: var { Res = 1 } in
: do Res after
: while N <> 0 do Res = N * Res; N = N + ~1
}
}
in
Out.WriteLine[/* Out; */ "Factorial of 10 is "; Fact[10]$]
}
It has absolutely all syntactic features and even makes sense!
- karmakaze 7y agoI find the nesting of elements hard to follow and would prefer something like: -- factorial (extern "manool.org.18/std/0.2/all") in: let: Fact = proc { N } as: unless N.IsI48[] & (N >= 1 - 1) signal (if (~)[N.IsI48[]] then TypeMismatch else InvariantViolation) else: var { Res = 1 } in do Res after while N <> 0 do Res = N * Res; N = N + ~1 in: Out.WriteLine[/* Out; */ "Factorial of 10 is "; Fact[10]$]