Skip to content
Jörg Mittag edited this page Oct 30, 2023 · 3 revisions

cons / car / cdr in λ

Recently, I was reminded about the nice λ-based implementation of Scheme’s cons, car and cdr “primitives” (or special forms, as Scheme calls them). Of course, being implemented just in terms of λ doesn’t actually make them so “primitive” any more.

This is a nice example of how not only code is data, but also data is code.

Here’s the Scheme code and ports to many other languages:

Untested

Clone this wiki locally