Hello everyone,
Here I am once more, begging for your professional guidance :).
I'm trying to write my own map function, but I want it to have an
unlimited number of arguments, as the built-in function of Lisp.
I'd like to pass it on to the internal map function, but the problem
arises: the data structures need to be preprocessed, but they shouldn't be
packed in a list.
This is what I've got:
(defmethod ds-map ((f function) (lst my-list) &rest data-structures)
(with-slots (contents) lst
(let ((result-list (map 'list f contents data-structures)))
(make-instance 'my-list :contents result-list))))
But the other data-structures need to be preprocessed as well, e.g. the
contents-slot should be extracted, but their contents shouldn't be wrapped
in a lisp-list.
Many thanks in advance,
Joris
In article <······························@nomasp.vub.ac.be>,
Joris Bleys <······@nomasp.vub.ac.be> wrote:
> Hello everyone,
>
> Here I am once more, begging for your professional guidance :).
>
> I'm trying to write my own map function, but I want it to have an
> unlimited number of arguments, as the built-in function of Lisp.
Use APPLY.
> I'd like to pass it on to the internal map function, but the problem
> arises: the data structures need to be preprocessed, but they shouldn't be
> packed in a list.
>
> This is what I've got:
>
> (defmethod ds-map ((f function) (lst my-list) &rest data-structures)
> (with-slots (contents) lst
> (let ((result-list (map 'list f contents data-structures)))
> (make-instance 'my-list :contents result-list))))
>
> But the other data-structures need to be preprocessed as well, e.g. the
> contents-slot should be extracted, but their contents shouldn't be wrapped
> in a lisp-list.
I'm not sure what you're saying about the contents slot, but I think you
want either:
(apply #'map 'list f contents data-structures)
or:
(apply #'map 'list f (append contents data-structures))
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***