From: Joris Bleys
Subject: writing own map function - with unlimited number of arguments
Date: 
Message-ID: <pan.2004.04.27.14.11.43.580121@nomasp.vub.ac.be>
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

From: Barry Margolin
Subject: Re: writing own map function - with unlimited number of arguments
Date: 
Message-ID: <barmar-E6CCC9.11535827042004@comcast.ash.giganews.com>
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 ***
From: Joris Bleys
Subject: Re: writing own map function - with unlimited number of arguments
Date: 
Message-ID: <pan.2004.04.27.16.03.20.498843@nomasp.vub.ac.be>
Ok, I'll give it a try.

Joris
From: Joris Bleys
Subject: Re: writing own map function - with unlimited number of arguments
Date: 
Message-ID: <pan.2004.05.06.15.35.43.886113@nomasp.vub.ac.be>
Ok, it worked !!

Thanks a lot !!

Joris