Another newbie (Common) LISP question:
Basically in most programming languages there\'s a mean for functions to receive references to variables instead of just value
As a beginner I came here to figure out how to do what should be a trivial procedure in any language. Most of the solutions posted above did not work properly, may have been more complicated than what was needed, or different implementations. Here is a simple solution for SBCL:
(defmacro inc-by-num (var num)
(set var (+ (eval var) num)))
Apparently you cannot use setf
b/c it restricts the scope whereas set
doesn't. Also you may need to use eval
before var
if you get an "argument X is not a number" error.