What exactly is a symbol in lisp/scheme?

In Scheme and Racket, a symbol is like an immutable string that happens to be interned so that symbols can be compared with eq? (fast, essentially pointer comparison). Symbols and strings are separate data types. One use for symbols is lightweight enumerations. For example, one might say a direction is either ‘north, ‘south, ‘east, or … Read more

I got “scheme application not a procedure” in the last recursive calling of a function

You intend to execute two expressions inside the consequent part of the if, but if only allows one expression in the consequent and one in the alternative. Surrounding both expressions between parenthesis (as you did) won’t work: the resulting expression will be evaluated as a function application of the first expression with the second expression … Read more

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

What is “point free” style (in Functional Programming)?

Just look at the Wikipedia article to get your definition: Tacit programming (point-free programming) is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition […] instead of variables. Haskell example: Conventional (you specify the arguments explicitly): sum (x:xs) = x + (sum xs) sum … Read more