[plt-scheme] Why no zip in "list.ss"?
Good grief! I don't know how you keep coming up with things that leave me thinking "Why didn't I think of that?"
Anyway, I noticed that the SRFI was in help desk, but didn't know how or if they were available for use.
Thanks.
--------------------------
Sent using BlackBerry
----- Original Message -----
From: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
To: Woodhouse, Gregory J.
Cc: plt-scheme at list.cs.brown.edu <plt-scheme at list.cs.brown.edu>
Sent: Wed Dec 27 12:59:35 2006
Subject: Re: [plt-scheme] Why no zip in "list.ss"?
> I could have sworn that zip was included in list.ss, but apparently not.
> Certainly, it seems a natural.
Hi Gregory,
Here's an alternative implementation that you might like:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define (zip l1 l2)
(map list l1 l2))
>
> (zip '(1 2 3 4 5) '(one two three four five))
((1 one) (2 two) (3 three) (4 four) (5 five))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
But the ZIP function you're thinking of does exist in the SRFI-1 "list"
library. We can also say:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (require (only (lib "1.ss" "srfi") zip))
>
> (zip '(1 2 3 4 5)
'(one two three four five))
((1 one) (2 two) (3 three) (4 four) (5 five))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
See:
http://download.plt-scheme.org/doc/360/html/srfi/srfi-1.html
http://download.plt-scheme.org/doc/360/html/r5rs/r5rs-Z-H-9.html#%25_idx_580
for more details. Good luck!