Today, 40.5 KB may seem like nothing, but in fact it is enough to run meaningful programs and even new programming environments. Despite the limited memory, the Spectrum had native compilers for C, Pascal, and even a Prolog interpreter.
The system provides an interactive top-level loop, with some built in support for generating church numerals, as well as macros (holding some predefined combinator expressions) for convenience (including factorial, fibonacci and Collatz sequence length (a.k.a. the 3n+1 or tnpo problem).
Although the combinator-reduction shown here looks primitive (e.g., there are no numbers, booleans, pairs or lists per se, they must be created from functions), these features are easily added. This core would allow a functional programming similar to Haskell.
The code was written in C, and runs on a ZX Spectrum, ZX Spectrum Next, on CP/M, and on modern machines, too. Here it’s shown running on a ZX Spectrum Next, which runs 8x faster than the original Spectrum; the exact same code would run on an ordinary Spectrum, just a little slower.
(Some typing has been sped up, and a couple moments where a typo was entered and corrected deleted, but otherwise computation times represent actual time.)