From: Michael Naunton
Subject: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <slrnab4bq4.fgo.mmn@mmn.bellatlantic.net>
I want to write something like

(apply #'or alist)

but of course #'or is a macro.  I wound up writing

(some (lambda (e) e) alist)

but that seems a bit strained.  I've played "guess the word" in the
HyperSpec, but can't find the idiom I want.

Any help would be appreciated,
Thanks,
Michael Naunton

From: Joe Marshall
Subject: Re: I can't find a simple CL function/idiom
Date: 
Message-ID: <M6qs8.12965$%s3.4994632@typhoon.ne.ipsvc.net>
"Michael Naunton" <···@bellatlantic.net> wrote in message
·······················@mmn.bellatlantic.net...
> I want to write something like
>
> (apply #'or alist)
>
> but of course #'or is a macro.  I wound up writing
>
> (some (lambda (e) e) alist)
>
> but that seems a bit strained.  I've played "guess the word" in the
> HyperSpec, but can't find the idiom I want.

(some #'identity alist)
(find-if #'identity alist)

Still kinda odd looking.
From: Erik Naggum
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <3227299206023244@naggum.net>
* Michael Naunton
| I wound up writing
| 
| (some (lambda (e) e) alist)
| 
| but that seems a bit strained.

  The function identity is predefined.

| I've played "guess the word" in the HyperSpec, but can't find the idiom I
| want.

  For a single list of arguments, some may or may not be misleading.

(find-if #'identity list)
(find-if-not #'null list)

  Note that the name "alist" connotes association lists, for which this
  operation makes little sense.

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg
From: Tim Moore
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <a8tb7t$rdq$0@216.39.145.192>
On Mon, 08 Apr 2002 23:44:27 GMT, Michael Naunton <···@bellatlantic.net> wrote:
>I want to write something like
>
>(apply #'or alist)
>
>but of course #'or is a macro.  I wound up writing
>
>(some (lambda (e) e) alist)
>
>but that seems a bit strained.  I've played "guess the word" in the
>HyperSpec, but can't find the idiom I want.

You could do (some #'identity alist).

You should avoid using apply for these kinds of idioms because you can
run into the call arguments limit fairly quickly.

Tim
From: Kent M Pitman
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <sfwit71afpu.fsf@shell01.TheWorld.com>
···@bellatlantic.net (Michael Naunton) writes:

> I want to write something like
> 
> (apply #'or alist)

For all but the most pathological alists (i.e., association lists),
FIRST will usually do the trick here. :-)

Maybe you meant (apply #'or list).

> but of course #'or is a macro.  I wound up writing
> 
> (some (lambda (e) e) alist)
> 
> but that seems a bit strained.  I've played "guess the word" in the
> HyperSpec, but can't find the idiom I want.

What's it called in other languages?

Lisp has a half dozen ultra trivial ways of saying this, which for as
often as it seems to come up seems more than adequate.  

 (loop for x in list thereis x)

 (find-if-not #'null x) ;or #'not

 (find-if #'identity x)

 (some #'identity x)

 (eval `(or ,@(mapcar #'(lambda (x) `',x) list)))

 ...


In the rare situation that I've had a system where this is common, I
have usually written a *OR or *AND function.

It's unfair to take an arbitrary action and complain that you have to
play "guess the word" when the thing you want to do is not even expressable
in most other languages.  The reason it's called a programming language
is that sometimes you have to program.
From: ozan s yigit
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <vi4zo0c7j86.fsf@blue.cs.yorku.ca>
Kent M Pitman:
	...
> It's unfair to take an arbitrary action and complain that you have to
> play "guess the word" when the thing you want to do is not even expressable
> in most other languages.

um, don't tempt the perl hackers who may be listening in. if there is some
part of common lisp perl programmers want but don't yet have, it will show
up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]

oz
-- 
you take a banana, you get a lunar landscape. -- j. van wijk
From: Marco Antoniotti
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <y6cbscsk48q.fsf@octagon.mrl.nyu.edu>
ozan s yigit <··@blue.cs.yorku.ca> writes:

> Kent M Pitman:
> 	...
> > It's unfair to take an arbitrary action and complain that you have to
> > play "guess the word" when the thing you want to do is not even expressable
> > in most other languages.
> 
> um, don't tempt the perl hackers who may be listening in. if there is some
> part of common lisp perl programmers want but don't yet have, it will show
> up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]

As it did in a Scheme SRFI a few years ago :)

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Reini Urban
Subject: Re: Help: I can't find a simple CL function/idiom
Date: 
Message-ID: <3cb34f81.468574784@news.jet2web.at>
ozan s yigit wrote:
>Kent M Pitman:
>> It's unfair to take an arbitrary action and complain that you have to
>> play "guess the word" when the thing you want to do is not even expressable
>> in most other languages.
>
>um, don't tempt the perl hackers who may be listening in. if there is some
>part of common lisp perl programmers want but don't yet have, it will show
>up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]

yes, but we don't care. 
they haven't even got the underlying basics (such as types) but want
catchy idioms. only perl hackers are proud of this post-modern
our-parser-understands-every-shit aeh we-do-it-all thing. 

for looking up common lisp idioms and perl programmers there's the
cl-cookbook project: http://cl-cookbook.sf.net/
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/film/
From: Paolo Amoroso
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <jQG0PHyI+3cOl+J5WfuR+vicL2w9@4ax.com>
On 09 Apr 2002 15:41:29 -0400, ozan s yigit <··@blue.cs.yorku.ca> wrote:

> um, don't tempt the perl hackers who may be listening in. if there is some
> part of common lisp perl programmers want but don't yet have, it will show
> up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]

Hmmm... does this imply that Mr. Wall's opinion on Lisp changed in some
way?


Paolo
-- 
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://www.paoloamoroso.it/ency/README
[http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/]
From: Reini Urban
Subject: Re: Help: I can't find a simple CL function/idiom
Date: 
Message-ID: <3cb44c19.533238386@news.jet2web.at>
Paolo Amoroso wrote:
>On 09 Apr 2002 15:41:29 -0400, ozan s yigit <··@blue.cs.yorku.ca> wrote:
>> um, don't tempt the perl hackers who may be listening in. if there is some
>> part of common lisp perl programmers want but don't yet have, it will show
>> up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]
>
>Hmmm... does this imply that Mr. Wall's opinion on Lisp changed in some
>way?

not him, but all the others around him.
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/film/
From: Mark Jason Dominus
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <a9e04f$hq6$1@plover.com>
In article <····························@4ax.com>,
Paolo Amoroso  <·······@mclink.it> wrote:
>On 09 Apr 2002 15:41:29 -0400, ozan s yigit <··@blue.cs.yorku.ca> wrote:
>
>> um, don't tempt the perl hackers who may be listening in. if there is some
>> part of common lisp perl programmers want but don't yet have, it will show
>> up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]
>
>Hmmm... does this imply that Mr. Wall's opinion on Lisp changed in some
>way?

I believe Larry's objection to Lisp has always been entirely on
syntactic grounds.


-- 
Mark Jason Dominus                                               ···@plover.com
Philadelphia Excursions Mailing List:    http://www.plover.com/~mjd/excursions/
From: Dr. Edmund Weitz
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <m3bsclmlj7.fsf@bird.agharta.de>
···@plover.com (Mark Jason Dominus) writes:

> In article <····························@4ax.com>,
> Paolo Amoroso  <·······@mclink.it> wrote:
> >On 09 Apr 2002 15:41:29 -0400, ozan s yigit <··@blue.cs.yorku.ca> wrote:
> >
> >> um, don't tempt the perl hackers who may be listening in. if there is some
> >> part of common lisp perl programmers want but don't yet have, it will show
> >> up in a perl6 rfc soon. :) [obhref: http://dev.perl.org/rfc/]
> >
> >Hmmm... does this imply that Mr. Wall's opinion on Lisp changed in some
> >way?
> 
> I believe Larry's objection to Lisp has always been entirely on
> syntactic grounds.

Really? What about this one?

  "Lispers are among the best grads of the
   Sweep-It-Under-Someone-Else's-Carpet School of Simulated
   Simplicity. [Was that sufficiently incendiary? :-)]"

This to me looks as if he's had an overdose of Scheme when he was
younger... :)

Cheers,
Edi.

-- 

Dr. Edmund Weitz
Hamburg
Germany

The Common Lisp Cookbook
<http://cl-cookbook.sourceforge.net/>
From: ozan s yigit
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <vi4bsclxbp8.fsf@blue.cs.yorku.ca>
···@agharta.de (Dr. Edmund Weitz) writes:

> > I believe Larry's objection to Lisp has always been entirely on
> > syntactic grounds.
> 
> Really? What about this one?
> 
>   "Lispers are among the best grads of the
>    Sweep-It-Under-Someone-Else's-Carpet School of Simulated
>    Simplicity. [Was that sufficiently incendiary? :-)]"
> 

that was a 92 post. CL was not quite what it is today. :)

> This to me looks as if he's had an overdose of Scheme when he was
> younger... :)

i think he only paid attention to scheme after he had already designed
and implemented perl. [btw, an important distinction about him is that he
articulates various linguistic aspects of his language, and why he thinks
it works well for programmers, eg. www.wall.org/~larry/natural.html or
state of the onion addresses. maybe his overdose is something else. :-]

oz
-- 
*double-sigh*cough*cough* -- eli barzilay
From: Erik Naggum
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <3227875769653775@naggum.net>
* ozan s yigit <··@blue.cs.yorku.ca>
| that was a 92 post. CL was not quite what it is today. :)

  It is still much more descriptive of people's experiences with Scheme.
  Even in 1992, Common Lisp was a real programming language suitable for
  production use.  It is unlikely that anyone would seriously argue against
  Common Lisp at that time as being "simulated simplicity".  That fake idea
  of "elegance" and "simplicity" has always been something to associated
  with Scheme and no other Lisp-lookalike.

| i think he only paid attention to scheme after he had already designed
| and implemented perl. [btw, an important distinction about him is that he
| articulates various linguistic aspects of his language, and why he thinks
| it works well for programmers, eg. www.wall.org/~larry/natural.html or
| state of the onion addresses. maybe his overdose is something else. :-]

  I think the Common Lisp designers were years ahead of him, there.  The
  Scheme folks obviously were not, focusing instead on formal semantics.
  It is kind of funny how much Perl has "stolen" from Common Lisp (but not
  from Scheme).  Both Common Lisp and Perl aim to be practical and useful.

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg
From: Paolo Amoroso
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <ZBW7PH+bpn6hPOQp4JH71=F9xRiM@4ax.com>
On 15 Apr 2002 10:45:23 -0400, ozan s yigit <··@blue.cs.yorku.ca> wrote:

[about Larry Wall]
> and implemented perl. [btw, an important distinction about him is that he
> articulates various linguistic aspects of his language, and why he thinks
> it works well for programmers, eg. www.wall.org/~larry/natural.html or

Anybody can easily create a software system that is a mess, and then
justify it by claiming that he purposely designed it that way in order to
mimic real life, which is well known to be a mess :)


Paolo
-- 
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://www.paoloamoroso.it/ency/README
[http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/]
From: Michael Naunton
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <slrnab732l.gja.mmn@mmn.bellatlantic.net>
On Tue, 9 Apr 2002 00:16:45 GMT, Kent M Pitman <······@world.std.com> wrote:
>···@bellatlantic.net (Michael Naunton) writes:
>
>> I want to write something like
>> 
>> (apply #'or alist)
>
>For all but the most pathological alists (i.e., association lists),
>FIRST will usually do the trick here. :-)
>

Thank you, after reading previous posts on the topic of naming, I will 
henceforth call a list a list.

<snip>

>In the rare situation that I've had a system where this is common, I
>have usually written a *OR or *AND function.

>It's unfair to take an arbitrary action and complain that you have to
>play "guess the word" when the thing you want to do is not even expressable
>in most other languages.  The reason it's called a programming language
>is that sometimes you have to program.

But, every other arbitrary action I've wanted to take has had a terse or
idiomatic expression in Common Lisp :)

Thanks to all for your help, 
-- MMN
From: Dr. Edmund Weitz
Subject: Re: Help:  I can't find a simple CL function/idiom
Date: 
Message-ID: <m3k7rhagxm.fsf@bird.agharta.de>
···@bellatlantic.net (Michael Naunton) writes:

> I want to write something like
> 
> (apply #'or alist)
> 
> but of course #'or is a macro.  I wound up writing
> 
> (some (lambda (e) e) alist)
> 
> but that seems a bit strained.  I've played "guess the word" in the
> HyperSpec, but can't find the idiom I want.

Maybe (find-if-not #'null alist).

-- 

Dr. Edmund Weitz
Hamburg
Germany

The Common Lisp Cookbook
<http://cl-cookbook.sourceforge.net/>