I enjoy writing programming languages. Example: Tiny. Let’s do that again.
This time, StackLang:
{
@[n fact]
1
{ n 1 - $fact fact n * }
N 1 <= if
} @fact
5 $fact fact writeln
Bit of gibberish there, I suppose, but the goal is to write everything in a postfix/stack based model. So n 1 - $fact fact n *
is equivalent to fact(fact, n - 1) * n
in a more traditional language.
Over the next few posts, I hope to write up where I am thus far and what’s next.