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