values function in Common Lisp

Multiple Values in CL The language Common lisp is described in the ANSI standard INCITS 226-1994 (R2004) and has many implementations. Each can implement multiple values as it sees fit, and they are allowed, of course, to cons up a list for them (in fact, the Emacs Lisp compatibility layer for CL does just that … Read more

Why do we need funcall in Lisp?

Strictly speaking, funcall would not be needed, but there are some lisps (lisp-2 variants, such as Common Lisp) that separate the variable name space of the function name space. Lisp-1 variants (e.g. Scheme) do not make this distinction. More specifically, in your case, test-func is in the variable name space. (defun foo (test-func args) (funcall … Read more

What does the f in setf stand for?

The actual meaning of F is often forgotten. According to some sources, f suffix could stand for: Field (see for example this answer) Form (as seen in various teaching materials and manuals) However, according to Gabriel and Steele’s The Evolution of Lisp, SETF comes from Peter Deutsch’s A Lisp Machine with Very Compact Programs (published … Read more

How do I increment or decrement a number in Common Lisp?

Use the built-in “+” or “-” functions, or their shorthand “1+” or “1-“, if you just want to use the result, without modifying the original number (the argument). If you do want to modify the original place (containing a number), then use the built-in “incf” or “decf” functions. Using the addition operator: (setf num 41) … Read more

Dr Racket problems with SICP

Even if possible, such redefinitions are not something that you should do without really understanding how the system will react to this. For example, if you redefine +, will any other code break? The answer to that in Racket’s case is “no” — but this is because you don’t really get to redefine +: instead, … Read more

tech