Subject: LISP puzzle
Date: Tue, 08 Oct 1996 10:46:37 -0700
From: Douglas Wilson <dougw@amgen.com>
Organization: Amgen
Newsgroups: comp.cad.autocad,
Message-ID: <325A937C.9BC@amgen.com>
References:

Once again, as a diversion, I pose this interesting LISP problem for those interested: write a function to 'transpose' a list e.g. For a list of 3D points, covert the list ((x1 y1 z1)(x2 y2 z2)...) to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...)) or for 2D points convert ((x1 y1)(x2 y2)(x3 y3) ...) to ((x1 x2 x3 ...)(y1 y2 y3 ...)) It should also work for 4, 5, or more or even 1 dimensional data. No (for,while,repeat) loops, no ifs or conds. Forgive me if no one is interested, or if an answer is commonly known, but this kind of problem is one of the reasons LISP is so cool.

--
Sincerly,
Doug Wilson(dougw@amgen.com)
*** The opinions expressed here are my own and not neccessarily ***
*** anyone elses ****
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!news.ecrc.de!newsgate.compuserve.com!imci4!pull-feed.internetmci.com!newsfeed.internetmci.com!news.webspan.net!www.nntp.primenet.com!nntp.primenet.com!feed1.news.erols.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!news.ecrc.de!newsgate.compuserve.com!imci4!pull-feed.internetmci.com!newsfeed.internetmci.com!news.webspan.net!www.nntp.primenet.com!nntp.primenet.com!feed1.news.erols.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 8 Oct 1996 18:49:51 GMT Organization: Design Automation Consulting Lines: 51 Message-ID: <01bbb549$378c4400$82dd92cf@pentiumpro> References: <325A937C.9BC@amgen.com> NNTP-Posting-Host: 130.st-louis-006.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

Sheesh. Got anything harder than this?

(defun list-transpose (l)
   (cond
      (  (not l) nil)
      (t (cons (mapcar 'car l)
               (list-tranpose (mapcar 'cdr l))
         )
      )
   )
)
--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Douglas Wilson <dougw@amgen.com> wrote in article <325A937C.9BC@amgen.com>...
> Once again, as a diversion, I pose this interesting LISP
> problem for those interested:
> write a function to 'transpose' a list e.g.
> For a list of 3D points,
> covert the list ((x1 y1 z1)(x2 y2 z2)...)
> to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...))
> or for 2D points
> convert ((x1 y1)(x2 y2)(x3 y3) ...)
> to ((x1 x2 x3 ...)(y1 y2 y3 ...))
> It should also work for 4, 5, or more or even 1 dimensional data.
> No (for,while,repeat) loops, no ifs or conds.
> Forgive me if no one is interested, or if an answer is
> commonly known, but this kind of problem is one of the reasons
> LISP is so cool.
> --
> Sincerly,
> Doug Wilson(dougw@amgen.com)
> *** The opinions expressed here are my own and not neccessarily ***
> *** anyone elses ****
> *** Disclaimer: These are the opinions of the poster not Amgen Inc.***
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!newspump.sol.net!posts.execpc.com!earth!rburns Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!newspump.sol.net!posts.execpc.com!earth!rburns From: rburns@earth.execpc.com (Robert Burns) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 9 Oct 1996 13:36:54 GMT Organization: Exec-PC Lines: 11 Message-ID: <53g9pm$qhg@newsops.execpc.com> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> NNTP-Posting-Host: earth-le1.execpc.com X-Newsreader: TIN [version 1.2 PL2]

Tony Tanzillo (tony.tanzillo@worldnet.att.net) wrote:
: Sheesh. Got anything harder than this?

: (defun list-transpose (l)

Doug:

Real AutoCAD Users - Know there's no point in answering lisp puzzles when Tony's around... <g> -Robert

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!news.rccn.net!global-one.pt!rain.fr!news.sprintlink.net!news-dc-9.sprintlink.net!www.nntp.primenet.com!nntp.primenet.com!cam-news-hub1.bbnplanet.com!uunet!in1.uu.net!amgen!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!news.rccn.net!global-one.pt!rain.fr!news.sprintlink.net!news-dc-9.sprintlink.net!www.nntp.primenet.com!nntp.primenet.com!cam-news-hub1.bbnplanet.com!uunet!in1.uu.net!amgen!usenet From: Douglas Wilson <dougw@amgen.com> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Wed, 09 Oct 1996 07:53:21 -0700 Organization: Amgen Lines: 32 Message-ID: <325BBC5F.1151@amgen.com> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Macintosh; I; 68K)

Tony Tanzillo wrote:
>
> Sheesh. Got anything harder than this?

Yes I do, but first ya ought to read the restrictions (think of them as hints) arbitrarily imposed (among them no conds) to which i'd like to add: No recursion, while elegant in the classroom, its often impractical in the real world. And use about 6 or 7 fewer 'words' in the function.

Answer to be posted later today (or tomorrow...) unless someone beats me to it.


> > Once again, as a diversion, I pose this interesting LISP
> > problem for those interested:
> > write a function to 'transpose' a list e.g.
> > For a list of 3D points,
> > covert the list ((x1 y1 z1)(x2 y2 z2)...)
> > to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...))
> > or for 2D points
> > convert ((x1 y1)(x2 y2)(x3 y3) ...)
> > to ((x1 x2 x3 ...)(y1 y2 y3 ...))
> > It should also work for 4, 5, or more or even 1 dimensional data.
> > No (foreach,while,repeat) loops, no ifs or conds. *** Disclaimer: These are the opinions of the poster not Amgen Inc.***

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!Austria.EU.net!EU.net!howland.erols.net!news.mathworks.com!uunet!in1.uu.net!amgen!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!Austria.EU.net!EU.net!howland.erols.net!news.mathworks.com!uunet!in1.uu.net!amgen!usenet From: Douglas Wilson <dougw@amgen.com> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Wed, 09 Oct 1996 13:14:49 -0700 Organization: Amgen Lines: 34 Message-ID: <325C07B9.7E15@amgen.com> References: <325A937C.9BC@amgen.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Macintosh; I; 68K)

Douglas Wilson wrote:
>
> Once again, as a diversion, I pose this interesting LISP
> problem for those interested:
> write a function to 'transpose' a list e.g.
> For a list of 3D points,
> covert the list ((x1 y1 z1)(x2 y2 z2)...)
> to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...))
> or for 2D points
> convert ((x1 y1)(x2 y2)(x3 y3) ...)
> to ((x1 x2 x3 ...)(y1 y2 y3 ...))
> It should also work for 4, 5, or more or even 1 dimensional data.
> No (for,while,repeat) loops, no ifs or conds.
> Forgive me if no one is interested, or if an answer is
> commonly known, but this kind of problem is one of the reasons
> LISP is so cool.
> -- Well, to all interested here's the solution:
(defun list-transpose (l) (apply 'mapcar (cons 'list l)))

so, Amaze your friends; Impress your boss; Confound your readers; Flunk your students; or, better yet Find a practical use for this. Enjoy. (By the way, does it even work?)

--
Sincerly,
Doug Wilson(dougw@amgen.com)
*** The opinions expressed here are my own and not neccessarily ***
*** anyone elses ****
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***

From fstgal00.tu-graz.ac.at!not-for-mail Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!not-for-mail From: rurban@xarch.tu-graz.ac.at (Reini Urban) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 10 Oct 1996 00:48:24 GMT Organization: Graz University of Technology, Austria Lines: 39 Message-ID: <53hh4o$kbi@fstgal00.tu-graz.ac.at> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> NNTP-Posting-Host: xarch.tu-graz.ac.at X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]

Tony Tanzillo (tony.tanzillo@worldnet.att.net) wrote:
: (defun list-transpose (l)
: (cond
: ( (not l) nil)
: (t (cons (mapcar 'car l)
: (list-tranpose (mapcar 'cdr l))
: )
: )
: )
: )
: Sheesh. Got anything harder than this?

Sure! search-replace with wildcard expansion in the replace string (maybe even standard regular expressions, or even winston-like AI)

Examples: (match "yes*" "no*") ;easy (match "(test)(.*)(me)" "\3\2\1") ;unix like for strings, but lisp is for lists and not strings so why not use it this way:

(match 	'(color (? x) red)
        '(color apple red)))	;winston like
 -> ((X APPLE))

Tip: winston horn: match.lsp at http://xarch.tu-graz.ac.at/autocad/lisp/FAQ-link/Winston/24match.exp

Or maybe a little triangulation if irregular shaped polygons. (optimal would be nice)

:) (just joking of course)

---
Reini Urban <rurban@xarch.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/
(defun union (x y)
  (cond ((null x) y)
        ((member (car x) y) (union (cdr x) y))
        (T (cons (car x) (union (cdr x) y)))))

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!jussieu.fr!math.ohio-state.edu!howland.erols.net!newsfeed.internetmci.com!in1.uu.net!amgen!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!jussieu.fr!math.ohio-state.edu!howland.erols.net!newsfeed.internetmci.com!in1.uu.net!amgen!usenet From: Douglas Wilson <dougw@amgen.com> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Thu, 10 Oct 1996 07:51:42 -0700 Organization: Amgen Lines: 18 Message-ID: <325D0D7C.218@amgen.com> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> <53g9pm$qhg@newsops.execpc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Macintosh; I; 68K)

Robert Burns wrote:
>
> Tony Tanzillo (tony.tanzillo@worldnet.att.net) wrote:
> : Sheesh. Got anything harder than this?
> Doug:
>
> Real AutoCAD Users - Know there's no point in answering lisp puzzles when
> Tony's around... <g>
>
> -Robert So, next time should I just stump Tony directly by email, and avoid sharing lisp puzzles with anyone else? Is everyone else that uninterested?

--
Sincerly,
Doug Wilson(dougw@amgen.com)
*** The opinions expressed here are my own and not neccessarily ***
*** anyone elses ****
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!news.ecrc.de!newsgate.compuserve.com!chi-news.cic.net!newspump.sol.net!www.nntp.primenet.com!nntp.primenet.com!news.enteract.com!ix.netcom.com!news Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!news.ecrc.de!newsgate.compuserve.com!chi-news.cic.net!newspump.sol.net!www.nntp.primenet.com!nntp.primenet.com!news.enteract.com!ix.netcom.com!news From: rscarr@ix.netcom.com (Robert S. Carroll) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Thu, 10 Oct 1996 16:56:40 GMT Organization: Netcom Lines: 24 Message-ID: <53ja3u$l38@sjx-ixn5.ix.netcom.com> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> <53g9pm$qhg@newsops.execpc.com> <325D0D7C.218@amgen.com> NNTP-Posting-Host: cin-oh4-25.ix.netcom.com X-NETCOM-Date: Thu Oct 10 10:00:46 AM PDT 1996 X-Newsreader: Forte Free Agent 1.0.82

Douglas Wilson <dougw@amgen.com> wrote:


>So, next time should I just stump Tony directly by email, and avoid
>sharing lisp puzzles with anyone else? Is everyone else that
>uninterested?
>--
>Sincerly,
>Doug Wilson(dougw@amgen.com)
>*** The opinions expressed here are my own and not neccessarily ***
>*** anyone elses ****
>*** Disclaimer: These are the opinions of the poster not Amgen Inc.***

Doug,

By all means , post more. It certainly fascinates me. It also is a great way for an autolisp "tinkerer" like myself to pick up on ideas and learn some of the more "elegant" methods of programing.

Sincerely, Robert S. Carroll rscarr@ix.netcom.com

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!surfnet.nl!howland.erols.net!EU.net!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!surfnet.nl!howland.erols.net!EU.net!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet From: jeeper@halcyon.com (Dennis Shinn) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Thu, 10 Oct 1996 19:13:09 GMT Organization: Northwest Nexus Inc. Lines: 20 Message-ID: <53ji65$ne3@news1.halcyon.com> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> NNTP-Posting-Host: blv-pm106-ip22.halcyon.com X-Newsreader: Forte Free Agent 1.0.82

Douglas Wilson <dougw@amgen.com> wrote:


>(defun list-transpose (l) (apply 'mapcar (cons 'list l)))

>(By the way, does it even work?)

Yeah ... it worked for me

Dennis Shinn Seattle AutoCAD User Group SAUG-BBS [206] 644-7115 [PCGNet]9:517/215 Anatech Systems Construction Detailing 3D modeling support for the construction industry http://www.halcyon.com/jeeper email: jeeper@halcyon.com

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 04:14:23 GMT Organization: Design Automation Consulting Lines: 89 Message-ID: <01bbb72a$67fd8d00$04de92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> NNTP-Posting-Host: 4.st-louis-007.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

In your original post, You said no loops.

Mapcar is a looping construct. It's exactly the same as foreach, except it doesn't return a result for each iteration, and requires the body to be expressed as a function, rather than an array of expressions. While you didn't explicitly restrict its use, it's a bit silly to say you can't use any loops but put forth a solution that uses a loop.

The only puzzle you've stumped me on is the word puzzle you used to describe the goal and the constraints.

Now, I've got one for you (and whoever else wants to have a go):

Given a list of arbitrary data, write a function that deletes all occurances of a given value from the list, without using any kind of conditional branching at all (you can use any kind of looping you want, but you may not use IF or COND).

Here's an example:

(setq mylist '(1 2 3 7 6 8 3 5 7 3))

(list-delete 3 mylist) -> (1 2 7 6 8 5 7)

First one to solve it gets a free copy of LispPad.

Unlike your problem, there's no word games or tricky semnantics.

Now let's see how good you really are. <grin>

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Douglas Wilson <dougw@amgen.com> wrote in article <325C07B9.7E15@amgen.com>...
> Douglas Wilson wrote:
> >
> > Once again, as a diversion, I pose this interesting LISP
> > problem for those interested:
> > write a function to 'transpose' a list e.g.
> > For a list of 3D points,
> > covert the list ((x1 y1 z1)(x2 y2 z2)...)
> > to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...))
> > or for 2D points
> > convert ((x1 y1)(x2 y2)(x3 y3) ...)
> > to ((x1 x2 x3 ...)(y1 y2 y3 ...))
> > It should also work for 4, 5, or more or even 1 dimensional data.
> > No (for,while,repeat) loops, no ifs or conds.
> > Forgive me if no one is interested, or if an answer is
> > commonly known, but this kind of problem is one of the reasons
> > LISP is so cool.
> > --
> Well, to all interested here's the solution:
> (defun list-transpose (l) (apply 'mapcar (cons 'list l)))
>
> so,
> Amaze your friends;
> Impress your boss;
> Confound your readers;
> Flunk your students; or, better yet
> Find a practical use for this.
> Enjoy.
> (By the way, does it even work?)
>
> --
> Sincerly,
> Doug Wilson(dougw@amgen.com)
> *** The opinions expressed here are my own and not neccessarily ***
> *** anyone elses ****
> *** Disclaimer: These are the opinions of the poster not Amgen Inc.***
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!arclight.uoregon.edu!feed1.news.erols.com!hunter.premier.net!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!arclight.uoregon.edu!feed1.news.erols.com!hunter.premier.net!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 04:32:05 GMT Organization: Design Automation Consulting Lines: 60 Message-ID: <01bbb72c$e2d0cf40$04de92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> NNTP-Posting-Host: 4.st-louis-007.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

One more note regarding the AutoLISP problem that I've just described: The first one that sends me an email with the solution to the problem gets a free copy of LispPad, but only if you email the response to me, and do not post it to the newsgroups (until I get the first correct solution).

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Douglas Wilson <dougw@amgen.com> wrote in article <325C07B9.7E15@amgen.com>...
> Douglas Wilson wrote:
> >
> > Once again, as a diversion, I pose this interesting LISP
> > problem for those interested:
> > write a function to 'transpose' a list e.g.
> > For a list of 3D points,
> > covert the list ((x1 y1 z1)(x2 y2 z2)...)
> > to ((x1 x2 ...)(y1 y2 ...)(z1 z2 ...))
> > or for 2D points
> > convert ((x1 y1)(x2 y2)(x3 y3) ...)
> > to ((x1 x2 x3 ...)(y1 y2 y3 ...))
> > It should also work for 4, 5, or more or even 1 dimensional data.
> > No (for,while,repeat) loops, no ifs or conds.
> > Forgive me if no one is interested, or if an answer is
> > commonly known, but this kind of problem is one of the reasons
> > LISP is so cool.
> > --
> Well, to all interested here's the solution:
> (defun list-transpose (l) (apply 'mapcar (cons 'list l)))
>
> so,
> Amaze your friends;
> Impress your boss;
> Confound your readers;
> Flunk your students; or, better yet
> Find a practical use for this.
> Enjoy.
> (By the way, does it even work?)
>
> --
> Sincerly,
> Doug Wilson(dougw@amgen.com)
> *** The opinions expressed here are my own and not neccessarily ***
> *** anyone elses ****
> *** Disclaimer: These are the opinions of the poster not Amgen Inc.***
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!Austria.EU.net!EU.net!newsfeed.internetmci.com!news.campus.mci.net!news.telis.org!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!Austria.EU.net!EU.net!newsfeed.internetmci.com!news.campus.mci.net!news.telis.org!usenet From: Rod Young <hermit1@ix.netcom.com> Newsgroups: comp.cad.autocad,alt.cad.autocad Subject: Re: LISP puzzle Date: Fri, 11 Oct 1996 06:11:20 -0700 Organization: Sierra Hermitage Lines: 88 Message-ID: <325E4778.3E60@ix.netcom.com> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72c$e2d0cf40$04de92cf@pentiumpro> NNTP-Posting-Host: s12-pm01-downy-t.telis.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Win95; I) Xref: fstgal00.tu-graz.ac.at comp.cad.autocad:30896 alt.cad.autocad:19412

Tony,

My solution might not be first, or best, but I think it might be the shortest.

Rod Young

--

Sierra Hermitage <http://www.netcom.com/~hermit1/intro.html> RUN LISP - batch acad R12 <ftp://ftp.coast.net/SimTel/win3/cad/rlisp2.zip> RUN LISP - batch acad R13 <ftp://ftp.coast.net/SimTel/win3/cad/rl32bit.zip> DIRECTORY TAMER - Simple EDM <ftp://ftp.coast.net/SimTel/win95/desktop/dtamer.zip> BATCH PLOT - auto plot dwgs <ftp://ftp.coast.net/SimTel/msdos/autocad/autoplot.zip> AUTO LOADER - alisp manage <ftp://ftp.coast.net/SimTel/win3/cad/aload20a.zip> AUTOBMP - dwg > bmp <ftp://ftp.coast.net/SimTel/msdos/autocad/autobmp2.zip> DWGDOC - attach file to dwg <ftp://ftp.coast.net/SimTel/msdos/autocad/dwgdocm.zip> FINDVARS - alisp helper <ftp://ftp.coast.net/SimTel/win3/cad/fvars2.zip>

From fstgal00.tu-graz.ac.at!not-for-mail Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!not-for-mail From: rurban@xarch.tu-graz.ac.at (Reini Urban) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 17:04:31 GMT Organization: Graz University of Technology, Austria Lines: 14 Message-ID: <53lumv$2il@fstgal00.tu-graz.ac.at> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <53ji65$ne3@news1.halcyon.com> NNTP-Posting-Host: xarch.tu-graz.ac.at X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]

Dennis Shinn (jeeper@halcyon.com) wrote:
: Douglas Wilson <dougw@amgen.com> wrote:
: >(defun list-transpose (l) (apply 'mapcar (cons 'list l)))
: >(By the way, does it even work?)
: Yeah ... it worked for me

funny, and what does this do: (defun puzzle (l)(apply 'mapcar 'list l))
can somebody tell me without testing it? or even
(defun another (l)(apply 'mapcar (apply 'list l)))

---
Reini Urban <rurban@xarch.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!www.nntp.primenet.com!nntp.primenet.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!www.nntp.primenet.com!nntp.primenet.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 18:10:01 GMT Organization: Design Automation Consulting Lines: 35 Message-ID: <01bbb79f$25b19a20$53dd92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <53ji65$ne3@news1.halcyon.com> <53lumv$2il@fstgal00.tu-graz.ac.at> NNTP-Posting-Host: 83.st-louis-006.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

It gives me a bad argument type error.

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Reini Urban <rurban@xarch.tu-graz.ac.at> wrote in article <53lumv$2il@fstgal00.tu-graz.ac.at>...
> Dennis Shinn (jeeper@halcyon.com) wrote:
> : Douglas Wilson <dougw@amgen.com> wrote:
> : >(defun list-transpose (l) (apply 'mapcar (cons 'list l)))
> : >(By the way, does it even work?)
> : Yeah ... it worked for me
>
> funny, and what does this do:
> (defun puzzle (l)(apply 'mapcar 'list l))
> can somebody tell me without testing it?
> or even
> (defun another (l)(apply 'mapcar (apply 'list l)))
>
> ---
> Reini Urban <rurban@xarch.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!feed1.news.erols.com!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!feed1.news.erols.com!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet From: jeeper@halcyon.com (Dennis Shinn) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Fri, 11 Oct 1996 18:13:16 GMT Organization: Northwest Nexus Inc. Lines: 21 Message-ID: <53m31r$b88@news1.halcyon.com> References: <325A937C.9BC@amgen.com> <01bbb549$378c4400$82dd92cf@pentiumpro> <53g9pm$qhg@newsops.execpc.com> <325D0D7C.218@amgen.com> NNTP-Posting-Host: blv-pm107-ip27.halcyon.com X-Newsreader: Forte Free Agent 1.0.82

Douglas Wilson <dougw@amgen.com> wrote:

> Is everyone else that
>uninterested?I'

Lets not let this turn into a roasting session for anyone, Doug. I enjoyed and profited from the exchange and would like to see more such puzzles. Understand I've just recently learned to consistently spell setq correctly so I don't have anything to offer in the way of solutions. None the less I learn a great deal watching the flow in this thread.

Dennis Shinn Seattle AutoCAD User Group SAUG-BBS [206] 644-7115 [PCGNet]9:517/215 Anatech Systems Construction Detailing 3D modeling support for the construction industry http://www.halcyon.com/jeeper email: jeeper@halcyon.com

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 18:24:25 GMT Organization: Design Automation Consulting Lines: 78 Message-ID: <01bbb7a1$297b8880$53dd92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72c$e2d0cf40$04de92cf@pentiumpro> NNTP-Posting-Host: 83.st-louis-006.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

And the winner is: Wenbiao Liang:

------begin quoted copy------------------------

Hi, Tony: Sorry, here is the correct version 2:

(defun _delete(item lst / sub blen slen n this temp)
  (while (setq sub (member item lst))
    (setq blen (length lst)
          slen (length sub)
             n -1
    )
    (while (< (setq n (1+ n)) (- blen slen))
      (setq this (nth n lst)
            temp (append temp (list this))
      )
    )
    (setq lst (cdr sub))
  )
  (foreach this lst
    (setq temp (append temp (list this)))
  )
  temp
)
Best regards, Wenbiao

---------------------------------------------------------

Here are the people who sent me replys in the order they were received:

Serge Volkov Paul Kohut Rod Young Lu Webiano Liang Darren Young Doug Wilson

Most of the responses failed to delete lists, as in:

   (list-delete '(a b) '(1 2 3 (a b) 4 5 6))

Which should return: (1 2 3 4 5 6)

Excluding Webiano, here's one more chance for each of you to win a free copy of LispPad:

The most-compact solution possible involves the use of only five AutoLISP functions, and the body of the (list-delete) function contains only one expression.

Four of the five functions used are APPLY, MAPCAR, SUBST, and LIST. There is one more which I will not disclose.

The first one of those listed above who emails me the most-compact solution possible wins.

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad,alt.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 20:42:04 GMT Organization: Design Automation Consulting Lines: 28 Message-ID: <01bbb7b4$64597080$53dd92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72c$e2d0cf40$04de92cf@pentiumpro> <325E4778.3E60@ix.netcom.com> NNTP-Posting-Host: 28.st-louis-007.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155 Xref: fstgal00.tu-graz.ac.at comp.cad.autocad:30963 alt.cad.autocad:19455

Not really, the most compact solution is actually much smaller than any of the solutions I've gotten.

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Rod Young <hermit1@ix.netcom.com> wrote in article <325E4778.3E60@ix.netcom.com>...
> Tony,
>
> My solution might not be first, or best, but I think it might be the
> shortest.
>
> Rod Young
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!super.zippo.com!zdc!zippo!news Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!super.zippo.com!zdc!zippo!news From: "Paul Kohut" <paulk2@seanet.com> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 11 Oct 1996 21:32:00 GMT Organization: Zippo Lines: 18 Message-ID: <01bbb7ba$9a900370$ad41b6cc@neversleep> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72c$e2d0cf40$04de92cf@pentiumpro> <01bbb7a1$297b8880$53dd92cf@pentiumpro> NNTP-Posting-Host: paulk2.seanet.com X-Newsreader: Microsoft Internet News 4.70.1155

Tony Tanzillo <tony.tanzillo@worldnet.att.net> wrote in article <01bbb7a1$297b8880$53dd92cf@pentiumpro>...

> Most of the responses failed to delete lists, as in:
>
> (list-delete '(a b) '(1 2 3 (a b) 4 5 6))
>
> Which should return: (1 2 3 4 5 6)
>

My second submission won't pass with these parameters either. I'll have to wait for the answer <g>, in the mean time it's back to work, with *pointers* and *classes* and MFC.

Later, Paul Kohut

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!news-peer.gsl.net!news.gsl.net!news-penn.gsl.net!news.gsl.net!news.NetVision.net.il!news Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!news-peer.gsl.net!news.gsl.net!news-penn.gsl.net!news.gsl.net!news.NetVision.net.il!news From: vnestr@netvision.net.il (Vladimir Nesterovsky) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Fri, 11 Oct 1996 23:27:03 GMT Organization: IDAN Computers Lines: 24 Message-ID: <53moa3$4gj@news.NetVision.net.il> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72a$67fd8d00$04de92cf@pentiumpro> NNTP-Posting-Host: ts014p3.pop4a.netvision.net.il X-Newsreader: Forte Free Agent 1.0.82

On 11 Oct 1996 04:14:23 GMT, - "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> wrote in comp.cad.autocad:

>Given a list of arbitrary data, write a function that
>deletes all occurances of a given value from the list,
>without using any kind of conditional branching at all
>(you can use any kind of looping you want, but you may
>not use IF or COND).

>Here's an example:
> (setq mylist '(1 2 3 7 6 8 3 5 7 3))
> (list-delete 3 mylist) -> (1 2 7 6 8 5 7)

>First one to solve it gets a free copy of LispPad.

Hello, everyone, I just sent my solution to Tony at 11/10 23:00 GMT. Have anyone else too?

Somebody have more puzzles like this one? -- Vladimir Nesterovsky ADS/LISP/C/C++ etc <vnestr@netvision.net.il>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!news-peer.gsl.net!news.gsl.net!news.mathworks.com!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!02-newsfeed.univie.ac.at!newsfeed.uk.ibm.net!news.ibm.net.il!arclight.uoregon.edu!news-peer.gsl.net!news.gsl.net!news.mathworks.com!uunet!in1.uu.net!nwnews.wa.com!news1.halcyon.com!usenet From: jeeper@halcyon.com (Dennis Shinn) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Sat, 12 Oct 1996 05:42:43 GMT Organization: Northwest Nexus Inc. Lines: 18 Message-ID: <53nbei$8f0@news1.halcyon.com> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72a$67fd8d00$04de92cf@pentiumpro> <53moa3$4gj@news.NetVision.net.il> NNTP-Posting-Host: blv-pm100-ip24.halcyon.com X-Newsreader: Forte Free Agent 1.0.82

vnestr@netvision.net.il (Vladimir Nesterovsky) wrote:

>Hello, everyone,
>I just sent my solution to Tony at 11/10 23:00 GMT.
>Have anyone else too?

I hope all the answers are posted here for "the rest of us" to marvel at.

Dennis Shinn Seattle AutoCAD User Group SAUG-BBS [206] 644-7115 [PCGNet]9:517/215 Anatech Systems Construction Detailing 3D modeling support for the construction industry http://www.halcyon.com/jeeper email: jeeper@halcyon.com

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!howland.erols.net!newsfeed.internetmci.com!hunter.premier.net!netnews.worldnet.att.net!newsadm Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!howland.erols.net!newsfeed.internetmci.com!hunter.premier.net!netnews.worldnet.att.net!newsadm From: "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 12 Oct 1996 10:14:39 GMT Organization: Design Automation Consulting Lines: 46 Message-ID: <01bbb825$e740b960$4adb92cf@pentiumpro> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72a$67fd8d00$04de92cf@pentiumpro> <53moa3$4gj@news.NetVision.net.il> <53nbei$8f0@news1.halcyon.com> NNTP-Posting-Host: 74.st-louis-004.mo.dial-access.att.net X-Newsreader: Microsoft Internet News 4.70.1155

Serge Volkov has solved the puzzle, here's the solution:

  (defun list-delete (expr lst)
     (apply 'append (subst nil (list expr) (mapcar 'list lst)))
  )
Everyone else feel free to post your submission to the newsgroup (there's too many of them for me to post).

--
/*******************************************************/
/*   Tony Tanzillo     Design Automation Consulting    */
/*    Expert AutoCAD Programming and Customization     */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */ /* Maximizing AutoLISP for AutoCAD R13 */ /* --------------------------------------------------- */ /* Contributing Author, CADENCE Magazine */ /* --------------------------------------------------- */ /* 71241.2067@compuserve.com */ /* tony.tanzillo@worldnet.att.net */ /* http://ourworld.compuserve.com/homepages/tonyt */ /*******************************************************/

Dennis Shinn <jeeper@halcyon.com> wrote in article <53nbei$8f0@news1.halcyon.com>...
> vnestr@netvision.net.il (Vladimir Nesterovsky) wrote:
>
> >Hello, everyone,
> >I just sent my solution to Tony at 11/10 23:00 GMT.
> >Have anyone else too?
>
> I hope all the answers are posted here for "the rest of us" to marvel at.
>
>
> Dennis Shinn
> Seattle AutoCAD User Group
> SAUG-BBS [206] 644-7115 [PCGNet]9:517/215
> Anatech Systems
> Construction Detailing
> 3D modeling support for the construction industry
> http://www.halcyon.com/jeeper
> email: jeeper@halcyon.com
>
>

From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!univ-lyon1.fr!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!super.zippo.com!zdc!zippo!news Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!univ-lyon1.fr!howland.erols.net!feed1.news.erols.com!arclight.uoregon.edu!super.zippo.com!zdc!zippo!news From: "Paul Kohut" <paulk2@seanet.com> Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: 12 Oct 1996 12:14:26 GMT Organization: Zippo Lines: 26 Message-ID: <01bbb835$fb373f60$ad41b6cc@neversleep> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72a$67fd8d00$04de92cf@pentiumpro> <53moa3$4gj@news.NetVision.net.il> <53nbei$8f0@news1.halcyon.com> <01bbb825$e740b960$4adb92cf@pentiumpro> NNTP-Posting-Host: paulk2.seanet.com X-Newsreader: Microsoft Internet News 4.70.1155

Tony Tanzillo <tony.tanzillo@worldnet.att.net> wrote in article <01bbb825$e740b960$4adb92cf@pentiumpro>...
> Serge Volkov has solved the puzzle, here's the solution:
>
> (defun list-delete (expr lst)
> (apply 'append (subst nil (list expr) (mapcar 'list lst)))
> )

Good work Serge.

>
> Everyone else feel free to post your submission to the newsgroup
> (there's too many of them for me to post).

Here's my submission with a correction to the while loop as suggested by Tony. The orignal had a while loop of (while (/= pt value). Thanks Tony.

; list-delete submission by Paul Kohut
(defun list-delete (value alist / newlist pt)
	(foreach pt alist (while (not (equal pt value))
			(setq newlist (append newlist (list pt)))
			(setq pt value)))
	(princ newlist)
	(princ)
)
From fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!uwm.edu!news-peer.gsl.net!news.gsl.net!news-penn.gsl.net!news.gsl.net!news.NetVision.net.il!news Mon Oct 14 01:37:46 1996 Path: fstgal00.tu-graz.ac.at!03-newsfeed.univie.ac.at!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!jussieu.fr!math.ohio-state.edu!uwm.edu!news-peer.gsl.net!news.gsl.net!news-penn.gsl.net!news.gsl.net!news.NetVision.net.il!news From: vnestr@netvision.net.il (Vladimir Nesterovsky) Newsgroups: comp.cad.autocad Subject: Re: LISP puzzle Date: Sat, 12 Oct 1996 22:29:56 GMT Organization: IDAN Computers Lines: 29 Message-ID: <53p9b2$rkr@news.NetVision.net.il> References: <325A937C.9BC@amgen.com> <325C07B9.7E15@amgen.com> <01bbb72a$67fd8d00$04de92cf@pentiumpro> <53moa3$4gj@news.NetVision.net.il> <53nbei$8f0@news1.halcyon.com> <01bbb825$e740b960$4adb92cf@pentiumpro> NNTP-Posting-Host: ts020p5.pop4a.netvision.net.il X-Newsreader: Forte Free Agent 1.0.82

On 12 Oct 1996 10:14:39 GMT, - "Tony Tanzillo" <tony.tanzillo@worldnet.att.net> wrote in comp.cad.autocad:

>Serge Volkov has solved the puzzle, here's the solution:

> (defun list-delete (expr lst)
> (apply 'append (subst nil (list expr) (mapcar 'list lst)))
> )

My solution was

(defun delist ( el lst)
 (apply 'append
  (mapcar ''((x)
    (apply
      (cdr (assoc (equal el x)
        (list (cons T ''((x)nil)) (cons nil 'list)) ))
      (list x) ))
    lst)))
I also used the feature of APPEND to eleminate NILs, but to get them I used more complicated MAPCAR. SUBST is killing the both targets -- makes them NIL and implies EQUAL.

-- Vladimir Nesterovsky ADS/LISP/C/C++ etc <vnestr@netvision.net.il>