From: Hubert =?ISO-8859-2?Q?Czobodzi=F1ski?=
Subject: conjunction of list elements
Date: 
Message-ID: <d485pr$fhp$3@news.onet.pl>
Hi,

I am quite newbie and I have to calculate conjunction (and alternative) of
all elements of list. Following seems to work:
(eval (cons 'and '(t t nil)))
but I'm not sure if it is "politically correct"... Any better methods?

Hubert

From: ···············@gmail.com
Subject: Re: conjunction of list elements
Date: 
Message-ID: <1114092960.268727.137870@z14g2000cwz.googlegroups.com>
You might look at the Lisp functions EVERY and SOME.

> (every 'identity '(t t t)) => T
> (every 'identity '(t nil t)) => NIL
> (some 'identity '(t nil t)) => T

Will Fitzgerald
From: Paul Dietz
Subject: Re: conjunction of list elements
Date: 
Message-ID: <d48js8$t92$1@avnika.corp.mot.com>
Hubert Czobodzin'ski wrote:
> Hi,
> 
> I am quite newbie and I have to calculate conjunction (and alternative) of
> all elements of list. Following seems to work:
> (eval (cons 'and '(t t nil)))
> but I'm not sure if it is "politically correct"... Any better methods?

(every 'identity <list>)
(some 'identity <list>)

	Paul
From: ·········@cern.ch
Subject: Re: conjunction of list elements
Date: 
Message-ID: <yzo4qe0cnnb.fsf@cern.ch>
(every #'identity (list t t nil))

EVAL you can pretty much forget about, at least for the coming 2-3
years:-)

Ole
From: Espen Vestre
Subject: Re: conjunction of list elements
Date: 
Message-ID: <kw8y3cnvl3.fsf@merced.netfonds.no>
·········@cern.ch writes:

> (every #'identity (list t t nil))

...which should make the OP reconsider how he came up with this
truth value list anyway!

> EVAL you can pretty much forget about, at least for the coming 2-3
> years:-)

Hmm? What happens in 2008?
-- 
  (espen)
From: Harald Hanche-Olsen
Subject: Re: conjunction of list elements
Date: 
Message-ID: <pco8y3cqnti.fsf@shuttle.math.ntnu.no>
+ Espen Vestre <·····@vestre.net>:

| ·········@cern.ch writes:
| 
| > EVAL you can pretty much forget about, at least for the coming 2-3
| > years:-)
| 
| Hmm? What happens in 2008?

My guess:  The OP has learned enough to know when to use eval.
Not to mention when not to use it, which is just about always.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Espen Vestre
Subject: Re: conjunction of list elements
Date: 
Message-ID: <kwzmvsmg3j.fsf@merced.netfonds.no>
Harald Hanche-Olsen <······@math.ntnu.no> writes:

> | Hmm? What happens in 2008?
>
> My guess:  The OP has learned enough to know when to use eval.
> Not to mention when not to use it, which is just about always.

Ah. Of course. 
-- 
  (espen)
From: Hubert =?ISO-8859-2?Q?Czobodzi=F1ski?=
Subject: Re: conjunction of list elements
Date: 
Message-ID: <d489gv$k7i$1@news.onet.pl>
>> (every #'identity (list t t nil))
> 
> ...which should make the OP reconsider how he came up with this
> truth value list anyway!

habet, hoc habet!
thanks,
h.
From: ·········@cern.ch
Subject: Re: conjunction of list elements
Date: 
Message-ID: <yzor7h4b6bl.fsf@cern.ch>
>> EVAL you can pretty much forget about, at least for the coming 2-3
>> years:-)

Espen> Hmm? What happens in 2008?

In 2008, Easter Sunday will be on March 23, and I'm allowing for the
possibility that the OP could come across some legitimate need for
EVAL sometime between that and the next time Easter falls on a still
earlier date.

Ole
From: Wade Humeniuk
Subject: Re: conjunction of list elements
Date: 
Message-ID: <nAP9e.46535$VF5.38266@edtnps89>
Besides the great suggestion of using some or every, you
can also use member:

(defun conjunction (list)
   (not (member nil list)))

CL-USER 8 > (conjunction '(t t nil))
NIL

CL-USER 9 > (conjunction '(t t t))
T

CL-USER 10 >

Wade
From: Hubert =?ISO-8859-2?Q?Czobodzi=F1ski?=
Subject: Re: conjunction of list elements
Date: 
Message-ID: <d48kjq$77s$1@news.onet.pl>
> Besides the great suggestion of using some or every, you
> can also use member:
> 
> (defun conjunction (list)
>    (not (member nil list)))

I asked rather how to 'apply' operator 'and' to whole list at once. Finally
I found out that idea of building such list was stupid.

BTW, variety of methods to accomplish one task in Lisp is little
confusing...

h.
From: GP lisper
Subject: Re: conjunction of list elements
Date: 
Message-ID: <1114111814.2399d37fbc2c1b0a8a1dce3b005e2b13@teranews>
On Thu, 21 Apr 2005 18:38:46 +0200, <···@poczta.rachu.onet.ciachu.pl> wrote:
>
> BTW, variety of methods to accomplish one task in Lisp is little
> confusing...

Better not consider perl then, TIMTOWTDI.

-- 
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
From: Wade Humeniuk
Subject: Re: conjunction of list elements
Date: 
Message-ID: <pnR9e.42915$yV3.28105@clgrps12>
Hubert Czobodzinski wrote:
>>Besides the great suggestion of using some or every, you
>>can also use member:
>>
>>(defun conjunction (list)
>>   (not (member nil list)))
> 
> 
> I asked rather how to 'apply' operator 'and' to whole list at once. Finally
> I found out that idea of building such list was stupid.
> 

I know that, but as you know one cannot APPLY AND.

> BTW, variety of methods to accomplish one task in Lisp is little
> confusing...
> 

Well, there is nothing wrong with being confused.

They may look like like different methods, but at their heart they are
the same.  (Once you understand the "principle" of what is going
on).


Wade
From: Kenny Tilton
Subject: Re: conjunction of list elements
Date: 
Message-ID: <bOU9e.10824$n93.8037@twister.nyc.rr.com>
Hubert Czobodzin'ski wrote:
>>Besides the great suggestion of using some or every, you
>>can also use member:
>>
>>(defun conjunction (list)
>>   (not (member nil list)))
> 
> 
> I asked rather how to 'apply' operator 'and' to whole list at once. Finally
> I found out that idea of building such list was stupid.
> 
> BTW, variety of methods to accomplish one task in Lisp is little
> confusing...

<g> as you get more familiar with the variety of methods you will stop 
seeing them as interchangeable, if only because one makes for more 
readable code (not that that is a minor consideration).

kenny


-- 
Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film

"Doctor, I wrestled with reality for forty years, and I am happy to 
state that I finally won out over it." -- Elwood P. Dowd