| 1 |
<html><head> |
| 2 |
|
| 3 |
<title>cl:expt</title> |
| 4 |
|
| 5 |
<style type="text/css"> |
| 6 |
.example { |
| 7 |
color: #000000; |
| 8 |
background-color: #F5F5F5; |
| 9 |
padding: 8px; |
| 10 |
border: #808080; |
| 11 |
border-style: solid; |
| 12 |
border-width: 1px; |
| 13 |
width:auto; |
| 14 |
} |
| 15 |
.button { |
| 16 |
color: #000000; |
| 17 |
background-color: #F5F5F5; |
| 18 |
padding-top: 1px; |
| 19 |
padding-bottom: 1px; |
| 20 |
padding-left: 4px; |
| 21 |
padding-right: 8px; |
| 22 |
border: #808080; |
| 23 |
border-style: solid; |
| 24 |
border-width: 1px; |
| 25 |
white-space: pre; |
| 26 |
} |
| 27 |
.box { |
| 28 |
color: #000000; |
| 29 |
padding-top: 4px; |
| 30 |
padding-bottom: 4px; |
| 31 |
padding-left: 16px; |
| 32 |
padding-right: 16px; |
| 33 |
border: #808080; |
| 34 |
border-style: solid; |
| 35 |
border-width: 1px; |
| 36 |
} |
| 37 |
</style> |
| 38 |
|
| 39 |
</head> |
| 40 |
|
| 41 |
<body> |
| 42 |
|
| 43 |
<a href="../../start.htm">Nyquist / XLISP 2.0</a> - |
| 44 |
<a href="../../manual/contents.htm">Contents</a> | |
| 45 |
<a href="../../tutorials/tutorials.htm">Tutorials</a> | |
| 46 |
<a href="../examples.htm">Examples</a> | |
| 47 |
<a href="../../reference/reference-index.htm">Reference</a> |
| 48 |
|
| 49 |
<hr> |
| 50 |
|
| 51 |
<h1>cl:expt</h1> |
| 52 |
|
| 53 |
<hr> |
| 54 |
|
| 55 |
<p>The <nobr>cl:<b>expt</b></nobr> function computes the result of 'x' to |
| 56 |
the power <nobr>of 'y'</nobr>:</p> |
| 57 |
|
| 58 |
<p><div class="box"> |
| 59 |
|
| 60 |
<dl> |
| 61 |
<dt>(cl:<b>expt</b> <i>base power</i>)</dt> |
| 62 |
<dd><i>base</i> - the base<br> |
| 63 |
<i>power</i> - the exponent<br> |
| 64 |
returns - the result of <i>base</i> to the power of <i>power</i></dd> |
| 65 |
</dl> |
| 66 |
|
| 67 |
</div></p> |
| 68 |
|
| 69 |
<pre class="example"> |
| 70 |
(defun <font color="#0000CC">cl:expt</font> (x y) |
| 71 |
(let ((power (expt (float x) y))) |
| 72 |
(if (and (integerp x) (integerp y)) |
| 73 |
(round power) |
| 74 |
power))) |
| 75 |
</pre> |
| 76 |
|
| 77 |
<p>See <a href="../reference/and.htm">and</a>, |
| 78 |
<a href="../reference/defun.htm">defun</a>, |
| 79 |
<a href="../reference/expt.htm">expt</a>, |
| 80 |
<a href="../reference/float.htm">float</a>, |
| 81 |
<nobr><a href="../reference/if.htm"> if </a></nobr>, |
| 82 |
<a href="../reference/integerp.htm">integerp</a>, |
| 83 |
<a href="../reference/let.htm">let</a>, |
| 84 |
<a href="../reference/power.htm">power</a>, |
| 85 |
<a href="../reference/round.htm">round</a>.</p> |
| 86 |
|
| 87 |
<p>The <nobr>cl:<b>expt</b></nobr> function accepts integer and floating |
| 88 |
point numbers as arguments. <nobr>If both</nobr> arguments are integer |
| 89 |
numbers, the result will be an integer number, <nobr>if one</nobr> or both |
| 90 |
arguments are <nobr>floating-point</nobr> numbers, the result will be a |
| 91 |
<nobr>floating-point</nobr> number. <nobr>In contrast</nobr> to the |
| 92 |
Nyquist/XLISP <a href="../../reference/expt.htm">expt</a> function, the |
| 93 |
'<nobr>cl:expt</nobr>' function accepts exactly two arguments.</p> |
| 94 |
|
| 95 |
<p><nobr> <a href="#top">Back to top</a></nobr></p> |
| 96 |
|
| 97 |
<hr> |
| 98 |
|
| 99 |
<a href="../../start.htm">Nyquist / XLISP 2.0</a> - |
| 100 |
<a href="../../manual/contents.htm">Contents</a> | |
| 101 |
<a href="../../tutorials/tutorials.htm">Tutorials</a> | |
| 102 |
<a href="../examples.htm">Examples</a> | |
| 103 |
<a href="../../reference/reference-index.htm">Reference</a> |
| 104 |
|
| 105 |
</body></html> |