Home

cond

Cond is a term used to denote a conditional construct in programming languages and logic. In Lisp family languages, cond is a built-in multi-branch conditional that selects among several possibilities based on tested conditions.

In Common Lisp and related dialects, a cond expression consists of a sequence of clauses. Each clause

Example in Scheme or Common Lisp: (cond ((< x 0) 'negative) ((= x 0) 'zero) (else 'positive)). This

Outside Lisp, cond is not a universal keyword, but the term remains a descriptive shorthand for conditional

See also: conditional expression, Lisp, Scheme, Emacs Lisp.

is
a
list
whose
first
element
is
a
test
expression
and
whose
remaining
elements
are
forms
to
evaluate
if
the
test
is
true.
The
first
clause
whose
test
evaluates
to
true
is
executed,
and
its
results
are
returned.
If
no
clause
matches,
the
value
is
nil
or
an
error
is
implementation-defined;
a
final
clause
with
a
test
of
t
(or
an
else
clause
in
Scheme)
provides
a
default
case.
evaluates
to
'negative,
'zero,
or
'positive
depending
on
x.
forms.
Other
languages
offer
similar
branching
constructs,
such
as
if-else,
switch/case,
or
pattern
matching.