File: cond.html

package info (click to toggle)
gcl 2.6.14-21
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 60,864 kB
  • sloc: ansic: 177,407; lisp: 151,509; asm: 128,169; sh: 22,510; cpp: 11,923; tcl: 3,181; perl: 2,930; makefile: 2,360; sed: 334; yacc: 226; lex: 95; awk: 30; fortran: 24; csh: 23
file content (112 lines) | stat: -rw-r--r-- 4,295 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>cond (ANSI and GNU Common Lisp Document)</title>

<meta name="description" content="cond (ANSI and GNU Common Lisp Document)">
<meta name="keywords" content="cond (ANSI and GNU Common Lisp Document)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Data-and-Control-Flow-Dictionary.html" rel="up" title="Data and Control Flow Dictionary">
<link href="if.html" rel="next" title="if">
<link href="and.html" rel="prev" title="and">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<span id="cond"></span><div class="header">
<p>
Next: <a href="if.html" accesskey="n" rel="next">if</a>, Previous: <a href="and.html" accesskey="p" rel="prev">and</a>, Up: <a href="Data-and-Control-Flow-Dictionary.html" accesskey="u" rel="up">Data and Control Flow Dictionary</a> &nbsp; </p>
</div>
<hr>
<span id="cond-_005bMacro_005d"></span><h4 class="subsection">5.3.42 cond                                                                [Macro]</h4>

<p><code>cond</code>  <i>{!<i>clause</i>}*</i> &rArr;  <i>{<i>result</i>}*</i>
</p>
<p><i>clause</i>&nbsp;::=<span class="roman">(</span><span class="nolinebreak">test-form</span>&nbsp;{<i>form</i>}*<span class="roman">)</span><!-- /@w -->
</p>
<span id="Arguments-and-Values_003a_003a-61"></span><h4 class="subsubheading">Arguments and Values::</h4>

<p><i>test-form</i>&mdash;a <i>form</i>.
</p>
<p><i>forms</i>&mdash;an <i>implicit progn</i>.
</p>
<p><i>results</i>&mdash;the <i>values</i> of the <i>forms</i> 
    in the first <i>clause</i> whose <i>test-form</i> <i>yields</i> <i>true</i>,
 or the <i>primary value</i> of the <i>test-form</i>
    if there are no <i>forms</i> in that <i>clause</i>,
 or else <b>nil</b> if no <i>test-form</i> <i>yields</i> <i>true</i>.
</p>
<span id="Description_003a_003a-95"></span><h4 class="subsubheading">Description::</h4>

<p><b>cond</b> allows the execution of <i>forms</i> to be dependent
on <i>test-form</i>.
</p>
<p><i>Test-forms</i> are evaluated one at a time in the order in which
they are given in the argument list until a <i>test-form</i> is found that
evaluates to <i>true</i>.
</p>
<p>If there are no <i>forms</i> in that clause, the <i>primary value</i> 
of the <i>test-form</i> is returned by the <b>cond</b> <i>form</i>.
Otherwise, the <i>forms</i> associated with this <i>test-form</i> are
evaluated in order, left to right, as an <i>implicit progn</i>, and the
<i>values</i> returned by the last <i>form</i> 
are returned by the <b>cond</b> <i>form</i>.
</p>
<p>Once one <i>test-form</i> has <i>yielded</i> <i>true</i>,
no additional <i>test-forms</i> are <i>evaluated</i>.
If no <i>test-form</i> <i>yields</i> <i>true</i>, <b>nil</b> is returned.
</p>
<span id="Examples_003a_003a-69"></span><h4 class="subsubheading">Examples::</h4>

<div class="example">
<pre class="example"> (defun select-options ()
   (cond ((= a 1) (setq a 2))
         ((= a 2) (setq a 3))
         ((and (= a 3) (floor a 2)))
         (t (floor a 3)))) &rArr;  SELECT-OPTIONS
 (setq a 1) &rArr;  1
 (select-options) &rArr;  2
 a &rArr;  2
 (select-options) &rArr;  3
 a &rArr;  3
 (select-options) &rArr;  1
 (setq a 5) &rArr;  5
 (select-options) &rArr;  1, 2
</pre></div>

<span id="See-Also_003a_003a-79"></span><h4 class="subsubheading">See Also::</h4>

<p><a href="if.html">if</a>
, 
<a href="case.html">case</a>
.
</p>



</body>
</html>