331 lines
No EOL
6.3 KiB
HTML
331 lines
No EOL
6.3 KiB
HTML
<!DOCTYPE HTML>
|
|
<HTML LANG="en-us"
|
|
><HEAD
|
|
><TITLE
|
|
>rotatef | Common Lisp Nova Spec</TITLE
|
|
><META CHARSET="US-ASCII"
|
|
><LINK REL="canonical" HREF="f_rotatef.html"
|
|
><LINK REL="next" HREF="t_control-error.html" TYPE="text/html" TITLE="control-error"
|
|
><LINK REL="prev" HREF="f_shiftf.html" TYPE="text/html" TITLE="shiftf"
|
|
><LINK REL="up" HREF="5_3_Data_and_Control_Flow_Dictionary.html" TYPE="text/html" TITLE="5.3 Data and Control Flow Dictionary"
|
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
|
></SCRIPT
|
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
|
></SCRIPT
|
|
></HEAD
|
|
><BODY
|
|
><DIV
|
|
><DIV CLASS="topnav"
|
|
><DIV CLASS="breadcrumb"
|
|
><SPAN CLASS="breadcrumb-item"
|
|
><A HREF="index.html"
|
|
>Common Lisp Nova Spec</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="5_Data_and_Control_Flow.html"
|
|
>5. Data and Control Flow</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="5_3_Data_and_Control_Flow_Dictionary.html"
|
|
>5.3 Data and Control Flow Dictionary</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="f_rotatef.html"
|
|
>rotatef</A
|
|
></SPAN
|
|
></DIV
|
|
><DIV CLASS="apropos"
|
|
><DIV CLASS="apropos-io"
|
|
><A HREF="f_shiftf.html" CLASS="prev"
|
|
>←</A
|
|
><SPAN ID="apropos-label"
|
|
>Apropos </SPAN
|
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
|
><A HREF="t_control-error.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV ID="apropos-res"
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="matter"
|
|
><DIV CLASS="com"
|
|
><DIV CLASS="begincom"
|
|
><HR
|
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
|
><TR
|
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="rotatef"
|
|
></SPAN
|
|
><B
|
|
>rotatef</B
|
|
></TD
|
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
|
><I
|
|
>Macro</I
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
></DIV
|
|
><UL CLASS="subtoc"
|
|
></UL
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Syntax</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><B
|
|
>rotatef</B
|
|
> {<VAR CLASS="param"
|
|
>place</VAR
|
|
>}* <SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
> <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Arguments and Values</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>place</VAR
|
|
> — a <A HREF="26_1_Glossary.html#place"
|
|
><EM CLASS="term"
|
|
>place</EM
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Description</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_rotatef.html" CLASS="macref"
|
|
><B
|
|
>rotatef</B
|
|
></A
|
|
> modifies the values of each <VAR CLASS="param"
|
|
>place</VAR
|
|
> by rotating values from one <VAR CLASS="param"
|
|
>place</VAR
|
|
> into another. </P
|
|
><P CLASS="j"
|
|
>If a <VAR CLASS="param"
|
|
>place</VAR
|
|
> produces more values than there are store variables, the extra values are ignored. If a <VAR CLASS="param"
|
|
>place</VAR
|
|
> produces fewer values than there are store variables, the missing values are set to <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
>. </P
|
|
><P CLASS="j"
|
|
>In the form <CODE CLASS="f"
|
|
>(rotatef <I CLASS="i"
|
|
><I
|
|
>place1</I
|
|
></I
|
|
> <I CLASS="i"
|
|
><I
|
|
>place2</I
|
|
></I
|
|
> ... <I CLASS="i"
|
|
><I
|
|
>placen</I
|
|
></I
|
|
>)</CODE
|
|
>, the values in <I CLASS="i"
|
|
><I
|
|
>place1</I
|
|
></I
|
|
> through <I CLASS="i"
|
|
><I
|
|
>placen</I
|
|
></I
|
|
> are <A HREF="26_1_Glossary.html#read"
|
|
><EM CLASS="term"
|
|
>read</EM
|
|
></A
|
|
> and <EM CLASS="term"
|
|
>written</EM
|
|
>. Values 2 through <I CLASS="i"
|
|
><I
|
|
>n</I
|
|
></I
|
|
> and value 1 are then stored into <I CLASS="i"
|
|
><I
|
|
>place1</I
|
|
></I
|
|
> through <I CLASS="i"
|
|
><I
|
|
>placen</I
|
|
></I
|
|
>. It is as if all the places form an end-around shift register that is rotated one place to the left, with the value of <I CLASS="i"
|
|
><I
|
|
>place1</I
|
|
></I
|
|
> being shifted around the end to <I CLASS="i"
|
|
><I
|
|
>placen</I
|
|
></I
|
|
>. </P
|
|
><P CLASS="j"
|
|
>For information about the <A HREF="26_1_Glossary.html#evaluation"
|
|
><EM CLASS="term"
|
|
>evaluation</EM
|
|
></A
|
|
> of <A HREF="26_1_Glossary.html#subform"
|
|
><EM CLASS="term"
|
|
>subforms</EM
|
|
></A
|
|
> of <VAR CLASS="param"
|
|
>places</VAR
|
|
>, see <A HREF="5_1_Generalized_Reference.html#sec_5_1_1_1" CLASS="secref"
|
|
><SPAN CLASS="cmr"
|
|
>Section</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>5.1.1.1</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>(Evaluation</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>of</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>Subforms</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>to</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>Places)</SPAN
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Examples</B
|
|
></DT
|
|
><DD
|
|
><PRE CLASS="screen"
|
|
>(let ((n 0)
|
|
(x (list 'a 'b 'c 'd 'e 'f 'g)))
|
|
(rotatef (nth (incf n) x)
|
|
(nth (incf n) x)
|
|
(nth (incf n) x))
|
|
x) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> (A C D B E F G)</PRE
|
|
></DD
|
|
><DT
|
|
><B
|
|
>See Also</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_define-setf-expander.html" CLASS="macref"
|
|
><B
|
|
>define-setf-expander</B
|
|
></A
|
|
>, <A HREF="f_defsetf.html" CLASS="macref"
|
|
><B
|
|
>defsetf</B
|
|
></A
|
|
>, <A HREF="f_setf.html" CLASS="macref"
|
|
><B
|
|
>setf</B
|
|
></A
|
|
>, <A HREF="f_shiftf.html" CLASS="macref"
|
|
><B
|
|
>shiftf</B
|
|
></A
|
|
>, <A HREF="v_macroexpand-hook.html" CLASS="varref"
|
|
><B
|
|
>*macroexpand-hook*</B
|
|
></A
|
|
>, <A HREF="5_1_Generalized_Reference.html#sec_5_1" CLASS="secref"
|
|
><SPAN CLASS="cmr"
|
|
>Section</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>5.1</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>(Generalized</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>Reference)</SPAN
|
|
></A
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Notes</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>The effect of <CODE CLASS="f"
|
|
>(rotatef <VAR CLASS="param"
|
|
>place1</VAR
|
|
> <VAR CLASS="param"
|
|
>place2</VAR
|
|
> ... <VAR CLASS="param"
|
|
>placen</VAR
|
|
>)</CODE
|
|
> is roughly equivalent to</P
|
|
><PRE CLASS="screen"
|
|
>(psetf <VAR CLASS="param"
|
|
>place1</VAR
|
|
> <VAR CLASS="param"
|
|
>place2</VAR
|
|
>
|
|
<VAR CLASS="param"
|
|
>place2</VAR
|
|
> <VAR CLASS="param"
|
|
>place3</VAR
|
|
>
|
|
...
|
|
<VAR CLASS="param"
|
|
>placen</VAR
|
|
> <VAR CLASS="param"
|
|
>place1</VAR
|
|
>)</PRE
|
|
><P CLASS="j"
|
|
>except that the latter would evaluate any <A HREF="26_1_Glossary.html#subform"
|
|
><EM CLASS="term"
|
|
>subforms</EM
|
|
></A
|
|
> of each <CODE CLASS="f"
|
|
>place</CODE
|
|
> twice, whereas <A HREF="f_rotatef.html" CLASS="macref"
|
|
><B
|
|
>rotatef</B
|
|
></A
|
|
> evaluates them once.</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="footer"
|
|
><DIV CLASS="btmnav"
|
|
><A HREF="f_shiftf.html" CLASS="prev"
|
|
>←</A
|
|
><A HREF="t_control-error.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV CLASS="trail"
|
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
|
></DIV
|
|
></DIV
|
|
><SCRIPT
|
|
>domReady();</SCRIPT
|
|
></BODY
|
|
></HTML
|
|
> |