Message from discussion
COND
Received: by 10.227.60.149 with SMTP id p21mr550977wbh.4.1322935197081;
Sat, 03 Dec 2011 09:59:57 -0800 (PST)
X-BeenThere: land-of-lisp@googlegroups.com
Received: by 10.180.81.101 with SMTP id z5ls11021254wix.0.gmail; Sat, 03 Dec
2011 09:59:56 -0800 (PST)
Received: by 10.180.14.33 with SMTP id m1mr1361672wic.2.1322935196408;
Sat, 03 Dec 2011 09:59:56 -0800 (PST)
Received: by 10.180.14.33 with SMTP id m1mr1361671wic.2.1322935196397;
Sat, 03 Dec 2011 09:59:56 -0800 (PST)
Return-Path: <gary.verhae...@gmail.com>
Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54])
by gmr-mx.google.com with ESMTPS id fc1si8468296wbb.2.2011.12.03.09.59.56
(version=TLSv1/SSLv3 cipher=OTHER);
Sat, 03 Dec 2011 09:59:56 -0800 (PST)
Received-SPF: pass (google.com: domain of gary.verhae...@gmail.com designates 74.125.82.54 as permitted sender) client-ip=74.125.82.54;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gary.verhae...@gmail.com designates 74.125.82.54 as permitted sender) smtp.mail=gary.verhae...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by mail-ww0-f54.google.com with SMTP id dt13so3298873wgb.11
for <land-of-lisp@googlegroups.com>; Sat, 03 Dec 2011 09:59:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=mime-version:sender:in-reply-to:references:date
:x-google-sender-auth:message-id:subject:from:to:content-type
:content-transfer-encoding;
bh=EmFXq9uDn3rdr5rZxZ2MHBirHm/+sdOesXbkDovAaO8=;
b=dEU11r2UJnbObaKqQNZ7orVIb9CF3h1pYTN9A5t0b3hpWhLxTadYEg61rLlq2OJKUx
gg+POgctaSNzzB8LWSRsSnYJ66PNZSGgn67uDevvZC8VKVV210G4GKJAm9MU9TzBWEkb
ZiJAusg03nxiyaT/xb6SCaBepfLv5/pcoh3VE=
MIME-Version: 1.0
Received: by 10.216.221.143 with SMTP id r15mr706267wep.71.1322935196149; Sat,
03 Dec 2011 09:59:56 -0800 (PST)
Sender: gary.verhae...@gmail.com
Received: by 10.227.2.195 with HTTP; Sat, 3 Dec 2011 09:59:56 -0800 (PST)
In-Reply-To: <96c2e3be-41e5-49d5-b79e-36be2dd3c...@v5g2000yqn.googlegroups.com>
References: <768236bc-9418-444c-bf07-02c3258b2...@p2g2000vbj.googlegroups.com>
<96c2e3be-41e5-49d5-b79e-36be2dd3c...@v5g2000yqn.googlegroups.com>
Date: Sat, 3 Dec 2011 18:59:56 +0100
Message-ID: <CAGqyAapRsm=xr2mLHo=jTB2CrzpkfUhDXwYWYUW8VUMk9b8...@mail.gmail.com>
Subject: Re: COND
From: Gary Verhaegen <Gary.Verhae...@ulb.ac.be>
To: land-of-lisp@googlegroups.com
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
It's actually (cond (condition1 result1) (condition2 result2) ...), so
for example (illustrative of cond; highly suboptimal):
(defun fibo(n)
(cond ((or (not (integerp n)) (< n 0)) (error "Arg must be a
positive integer"))
((=3D 0 n) 1)
((=3D 1 n) 1)
((=3D 2 n) 2)
(t (+ (fibo (1- n)) (fibo (- n 2))))))
The conditions do not really need to be boolean operations, though. As
far as I can tell, Common Lisp does not even really have the notion of
a boolean: the empty list, written as either (), '() or nil, is
considered false in a boolean context, while any other value is
considered true. There is neither a separate "False" value, nor a
separate "True" value. t is juste the object at the top of the CLOS
hierarchy, which makes it the canonical "non-nil" value.
On Sat, Dec 3, 2011 at 18:11, Havvy <ryan.ha...@gmail.com> wrote:
> (cond condition1 result1 condition2 result2 ... conditionN resultN)
>
> conditionN just has to evaluate to a boolean. =C2=A0You can you boolean
> operators to conjunct (compose together) multiple simple conditions.
>
> (and (=3D 5 5) (!=3D 5 4))
>
> [Caveat: =C2=A0I haven't seen Common Lisp for about half a year, so check
> to see where brackets are necessary]
>
> On Dec 3, 5:00=C2=A0am, vikifor <viktorijastojko...@gmail.com> wrote:
>> Hi
>> I have one question.How can I put many condition in COND in some
>> function
>> Thanks