diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/modifying-lists.html | |
new repository
Diffstat (limited to 'devdocs/elisp/modifying-lists.html')
| -rw-r--r-- | devdocs/elisp/modifying-lists.html | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/devdocs/elisp/modifying-lists.html b/devdocs/elisp/modifying-lists.html new file mode 100644 index 00000000..b2eae408 --- /dev/null +++ b/devdocs/elisp/modifying-lists.html @@ -0,0 +1,22 @@ + <h3 class="section">Modifying Existing List Structure</h3> <p>You can modify the <small>CAR</small> and <small>CDR</small> contents of a cons cell with the primitives <code>setcar</code> and <code>setcdr</code>. These are destructive operations because they change existing list structure. Destructive operations should be applied only to mutable lists, that is, lists constructed via <code>cons</code>, <code>list</code> or similar operations. Lists created by quoting are part of the program and should not be changed by destructive operations. See <a href="mutability">Mutability</a>. </p> <blockquote> <p><b>Common Lisp note:</b> Common Lisp uses functions <code>rplaca</code> and <code>rplacd</code> to alter list structure; they change structure the same way as <code>setcar</code> and <code>setcdr</code>, but the Common Lisp functions return the cons cell while <code>setcar</code> and <code>setcdr</code> return the new <small>CAR</small> or <small>CDR</small>. </p> +</blockquote> <table class="menu" border="0" cellspacing="0"> <tr> +<td align="left" valign="top">• <a href="setcar" accesskey="1">Setcar</a> +</td> +<td> </td> +<td align="left" valign="top">Replacing an element in a list. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="setcdr" accesskey="2">Setcdr</a> +</td> +<td> </td> +<td align="left" valign="top">Replacing part of the list backbone. This can be used to remove or add elements. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="rearrangement" accesskey="3">Rearrangement</a> +</td> +<td> </td> +<td align="left" valign="top">Reordering the elements in a list; combining lists. </td> +</tr> </table><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Modifying-Lists.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Modifying-Lists.html</a> + </p> +</div> |
