Flatten a list using only the forms in “The Little Schemer”

I have a version that uses only “first-principles” operations and is efficient (does not require more than one pass through any of the lists, unlike append-based solutions). 🙂 It does this by defining two simple building blocks (fold and reverse), and then defining flatten (and its helper, reverse-flatten-into) atop those (and notice how each function … Read more