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

tail-recursive function appending element to list

The following is an implementation of tail recursion modulo cons optimization, resulting in a fully tail recursive code. It copies the input structure and then appends the new element to it, by mutation, in the top-down manner. Since this mutation is done to its internal freshly-created data, it is still functional on the outside (does … Read more

My code signals the error “application: not a procedure” or “call to non procedure”

Why is it happening Scheme procedure/function calls look like this: (operator operand …) Both operator and operands can be variables like test, and + that evaluates to different values. For a procedure call to work it has to be a procedure. From the error message it seems likely that test is not a procedure but … Read more