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
|
<!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>nth-value (ANSI and GNU Common Lisp Document)</title>
<meta name="description" content="nth-value (ANSI and GNU Common Lisp Document)">
<meta name="keywords" content="nth-value (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="prog.html" rel="next" title="prog">
<link href="multiple_002dvalues_002dlimit.html" rel="prev" title="multiple-values-limit">
<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="nth_002dvalue"></span><div class="header">
<p>
Next: <a href="prog.html" accesskey="n" rel="next">prog</a>, Previous: <a href="multiple_002dvalues_002dlimit.html" accesskey="p" rel="prev">multiple-values-limit</a>, Up: <a href="Data-and-Control-Flow-Dictionary.html" accesskey="u" rel="up">Data and Control Flow Dictionary</a> </p>
</div>
<hr>
<span id="nth_002dvalue-_005bMacro_005d"></span><h4 class="subsection">5.3.56 nth-value [Macro]</h4>
<p><code>nth-value</code> <i>n form</i> ⇒ <i>object</i>
</p>
<span id="Arguments-and-Values_003a_003a-74"></span><h4 class="subsubheading">Arguments and Values::</h4>
<p><i>n</i>—a non-negative <i>integer</i>; evaluated.
</p>
<p><i>form</i>—a <i>form</i>; evaluated as described below.
</p>
<p><i>object</i>—an <i>object</i>.
</p>
<span id="Description_003a_003a-109"></span><h4 class="subsubheading">Description::</h4>
<p>Evaluates <i>n</i> and then <i>form</i>,
returning as its only value the <i>n</i>th value <i>yielded</i> by <i>form</i>,
or <b>nil</b> if <i>n</i> is greater than or equal to the number of <i>values</i>
returned by <i>form</i>. (The first returned value is numbered <tt>0</tt>.)
</p>
<span id="Examples_003a_003a-82"></span><h4 class="subsubheading">Examples::</h4>
<div class="example">
<pre class="example"> (nth-value 0 (values 'a 'b)) ⇒ A
(nth-value 1 (values 'a 'b)) ⇒ B
(nth-value 2 (values 'a 'b)) ⇒ NIL
(let* ((x 83927472397238947423879243432432432)
(y 32423489732)
(a (nth-value 1 (floor x y)))
(b (mod x y)))
(values a b (= a b)))
⇒ 3332987528, 3332987528, <i>true</i>
</pre></div>
<span id="See-Also_003a_003a-93"></span><h4 class="subsubheading">See Also::</h4>
<p><a href="multiple_002dvalue_002dlist.html">multiple-value-list</a>
,
<a href="nth.html">nth</a>
</p>
<span id="Notes_003a_003a-60"></span><h4 class="subsubheading">Notes::</h4>
<p>Operationally, the following relationship is true, although <b>nth-value</b>
might be more efficient in some <i>implementations</i>
because, for example, some <i>consing</i> might be avoided.
</p>
<div class="example">
<pre class="example"> (nth-value <i>n</i> <i>form</i>) ≡ (nth <i>n</i> (multiple-value-list <i>form</i>))
</pre></div>
</body>
</html>
|