Can anyone tell me how to work with the parameters stored in the value specified by &rest.
I’ve read around a lot and it seems as if authors only know how to list all the parameters as so.
(defun test (a &rest b) b)
This is nice to see, but not really that useful.
The best I’ve found so far is to use first, second, and so on to get the parameter you are looking for.
(defun test (a &rest b) (first b))
I noticed this method stops working at the tenth parameter, but the specification (from what I’ve read) supports a minimum of 50. Even if the chances are slim that I’ll use 50 parameters, I’d like to know how to access them all.
Thanks
The FIRST, SECOND and so on accessor functions are ‘just’ utility functions on top of CAR/CDR or NTH. SO, I guess, the answer to your specific question is ‘use NTH or ELT’ (or build your own specific acccessor functions).
If you want, you can define an ELEVENTH as:
I find, however, that I mostly use &REST arguments when there’s 0 or more things I want to do something with, not really caring about the specific position of a given argument in the &REST list. That usually entails using LOOP, DO or DOLIST to traverse the arguments and do something with each one; the MAP family or (occasionally) REDUCE.