Scheme in about 10 lines of Javascript

A completely impractical use of your limited time

What is Scheme?

A functional languange with a minimal core. It relies on first-class functions to implement lists, and recursion for iteration.

We can implement the most salient features of Scheme in about 10 lines of Javascript.

Why? Because it's there.

What we need

Creating a pair

Getting the first part

Getting the second part

Scheme in about 10 lines of Javascript

It works


... but what is it?


Taking it further

What if we nest pairs?


We've got a list, and we can get at its elements using head and tail

List

We can use some native Javascript to implement the list function:

Building up some more

Examples

/

#