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

When to use ‘ (or quote) in Lisp?

Short answer Bypass the default evaluation rules and do not evaluate the expression (symbol or s-exp), passing it along to the function exactly as typed. Long Answer: The Default Evaluation Rule When a regular (I’ll come to that later) function is invoked, all arguments passed to it are evaluated. This means you can write this: … Read more