Subject: Re: It's A Big Language Survey
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 29 Apr 2009 20:15:37 -0500
Newsgroups: comp.lang.lisp
Message-ID: <bJWdnQ1HF8YkZmXUnZ2dnUVZ_hOdnZ2d@speakeasy.net>
szergling  <senatorZergling@gmail.com> wrote:
+---------------
| Pillsy <pillsb...@gmail.com> wrote:
| > (defun zip (&rest more-lists)
| >   (apply #'mapcan #'list more-lists))
| 
| CL-USER> (zip '(1 2 3) '(4 5 6))
| (1 4 2 5 3 6)
| 
| This actually looks like a real zipper!
| Doesn't zip usually refer to this (eg Python)?
| 
| CL-USER> (defun zip (&rest lists)
|            (apply #'mapcar #'list lists))
| ZIP
| CL-USER> (zip '(1 2 3) '(4 5 6))
| ((1 4) (2 5) (3 6))
| CL-USER>
+---------------

To bring us back to obscure features of CL... Note that CL
already has a function with semantics similar to the latter:

    > (pairlis '(1 2 3) '(4 5 6))

    ((3 . 6) (2 . 5) (1 . 4))
    > (pairlis '(1 2 3) '(4 5 6) '((x . y) (z . w)))

    ((3 . 6) (2 . 5) (1 . 4) (X . Y) (Z . W))
    > 

And while we're in that part of town, don't forget ACONS:

    > (acons 1 4
	(acons 2 5
	  (acons 3 6 nil)))

    ((1 . 4) (2 . 5) (3 . 6))
    > 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607