[plt-scheme] How to de-structure(?) a list for a call to map?
On Nov 12, 2007 2:27 PM, Grant Rettke <grettke at acm.org> wrote:
> The result of a function I'm calling is a list of lists. I need to
> pass those lists in as a call to map.
>
> Here is a approximation:
>
> (define *rows* '((1 2 3) (2 3 4) (3 4 5)))
>
> Here is what I want to be able to do, though:
>
> (map list '(1 2 3) '(2 3 4) '(3 4 5))
>
> to produce
>
> ((1 2 3) (2 3 4) (3 4 5))
>
> but using the contents of *rows* instead.
Another solution is to use unzip3 from SRFI-1:
(receive (ls1 ls2 ls3) (unzip3 '((1 2 3) (2 3 4) (3 4 5)))
(map list ls1 ls2 ls3))
though that's assuming a fixed 3 rows.
--
Alex