4 ms·
The syntax is close to Scheme and with small changes will run in a Scheme interpreter. For example, here's a session at the REPL of Racket: ~$ racket Welco
by tonyg 7y ago
The syntax is close to Scheme and with small changes will run in a Scheme interpreter. For example, here's a session at the REPL of Racket:
~$ racket
Welcome to Racket v7.2.0.6.
> (define True (lambda (t f) (t)))
> (define False (lambda (t f) (f)))
> (define If (lambda (b tr fa) (b tr fa)))
> (define P (lambda (x)
(If x
(lambda () (display "It was true!"))
(lambda () (display "It was false!")))))
> (P True)
It was true!
> (P False)
It was false!
>
Seen differently, it's also close to the mathematical notation of the lambda calculus.
To learn about the lambda calculus, check out chapter 5 of "Types and Programming Languages", Benjamin C. Pierce, MIT Press 2002. You might also get something out of "Semantics Engineering with PLT Redex", Felleisen, Findler & Flatt, MIT Press 2009.
- tonyg 7y agoOh, see also https://en.wikipedia.org/wiki/Mogensen%E2%80%93Scott_encoding https://en.wikipedia.org/wiki/Mogensen%E2%80%93Scott_encodin... for a quick overview of Church and Scott encodings. (Ignore the stuff about Mogensen-Scott. Also, you'll need to have played around with lambda calculus a bit for this stuff to make sense. This kind of thing might be helpful: https://jacksongl.github.io/files/demo/lambda/index.htm https://jacksongl.github.io/files/demo/lambda/index.htm)