> (declaim (inline square)) > (defun square (x)(* x x)) > > (defun square-vector (x z) > (declare (type (simple-array double-float (*)) x z))) > (dotimes (i (min (length x)(length z)) > (declare (optimize (safety 0)(fixnum i))) > (setf (aref z i)(square (aref x i)))) > z) >
But this seems to only be better than just putting square inside square-vector if square becomes an argument, i.e., if the function becomes something like operate-on-vector, as otherwise I still have to write separate functions akin to square-vector for each of many operations I want to perform mapping vectors to vectors. This in turn seems to imply a macro based solution, so that at each instantiation, the system can know at compile time what the function is. I'm currently playing with Gabe Garza's solution. But it's definitely useful to know that in this case, I don't have to declare the types to inside square because they can be inferred. Cheers, rif
