Out of boredom, I created a project that represents lambda calculus terms as list structures, and provides blocks for constructing, reducing and converting them to other forms.
As an example of what you can do, this is how you might use Snap! to construct the 'successor' function for Church numerals:
(Don't mind the control block =
, that's just there so you can define variables within reporters. The new var
block reports a new variable every time, which is why it's necessary here. You can still construct terms without it!)
Here is the resulting data structure, blockified for visibility:
Those numerical IDs are used to disambiguate between different variables with the same name.
You can convert lambda terms back into constructor blocks:
Calling the reported procedure reports back the original data structure.
You can convert terms into text:
You can convert them into working Snap! procedures, thanks to the new script-building capabilities of the join
and split
blocks:
This can be used to convert values into other Snap!-friendly forms, such as church numerals into Snap! numbers: