[plt-scheme] How to de-structure(?) a list for a call to map?

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Mon Nov 12 08:36:00 EST 2007

On Nov 12, 2007 12:39 AM, Jon Rafkind <workmin at ccs.neu.edu> wrote:
> Grant Rettke wrote:
> >
> > 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))
> >
> (apply map list *rows*)

It took me a while to figure out what the heck this was accomplishing,
because the input is the same as the output in the example above.  Of
course, that's a quirk of the input.  What you really want is for

(apply map list '((1 2 3) (4 5 6) (7 8 9)))

to produce

((1 4 7) (2 5 8) (3 6 9))

which it does, so the solution works, but this example is more illustrative.  :)

-- 
Carl Eastlund


Posted on the users mailing list.