From: Pascal J. Bourguignon <pjb@in...>  20120303 17:25:57

Giovanni Gigante <giov@...> writes: > I'd rather write the first one like this: > > (defun middadd (x) > (incf (second x)) > x) > > The second one: I am not sure what you're trying to do, but first, on a > syntactic level, note that you forgot a pair of parentheses in your > LET*. It should (in theory) be: > > (defun middaddlet (x) ; slightly less wrong > (let* (((second x) (+ (second x) 1))) > x)) Worse and worser… Gerard's: (defun middaddlet (x) (let* ((second x) (+ (second x) 1)) x)) doesn't work because it gives two values to bind to the variable + instead of one. (defun middaddlet (x) (let* ((second x) (+ (second x))) x)) will work, and means, assuming defun is CL:DEFUN, let* is CL:LET* and second is CL:SECOND: Bind the value of the parameter X to a variable named SECOND, then bind the SECOND element of X to a variable named +. Assuming that X is bound to either a properlist, a circularlist, or a improperlist made of at least two conses, otherwise an error will be signaled by the function SECOND. And finally, return the value of the parameter X. Therefore the above is useless (dead code) and the function can be writte as: (defun middaddlet (x) x) or one can just use the function IDENTITY. (Or read a tutorial and CLHS as I advised previously).  __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. 