diff options
| author | Gerd Moellmann | 2000-08-15 13:22:09 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-08-15 13:22:09 +0000 |
| commit | f68446efd37a6ee25e8ed0f14231bfe457aaeb9d (patch) | |
| tree | 3b63dcc5a5a173f1ff6a4aeb0df786de2bcca4c1 /lispref | |
| parent | 9105187020025123f64e48f2f735babb329cd09a (diff) | |
| download | emacs-f68446efd37a6ee25e8ed0f14231bfe457aaeb9d.tar.gz emacs-f68446efd37a6ee25e8ed0f14231bfe457aaeb9d.zip | |
*** empty log message ***
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/lists.texi | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi index 661c8c35308..64e634d2803 100644 --- a/lispref/lists.texi +++ b/lispref/lists.texi | |||
| @@ -663,6 +663,31 @@ x | |||
| 663 | @end example | 663 | @end example |
| 664 | @end defun | 664 | @end defun |
| 665 | 665 | ||
| 666 | @defun remq object list | ||
| 667 | This function returns a copy of @var{list}, with all elements removed | ||
| 668 | which are @code{eq} to @var{object}. The letter @samp{q} in @code{remq} | ||
| 669 | says that it uses @code{eq} to compare @var{object} against the elements | ||
| 670 | of @code{list}. | ||
| 671 | |||
| 672 | @example | ||
| 673 | @group | ||
| 674 | (setq sample-list '(a b c a b c)) | ||
| 675 | @result{} (a b c a b c) | ||
| 676 | @end group | ||
| 677 | @group | ||
| 678 | (remq 'a sample-list) | ||
| 679 | @result{} (b c b c) | ||
| 680 | @end group | ||
| 681 | @group | ||
| 682 | sample-list | ||
| 683 | @result{} (a b c a b c) | ||
| 684 | @end group | ||
| 685 | @end example | ||
| 686 | @noindent | ||
| 687 | The function @code{delq} offers a way to perform this operation | ||
| 688 | destructively. See @ref{Sets And Lists}. | ||
| 689 | @end defun | ||
| 690 | |||
| 666 | @node Modifying Lists | 691 | @node Modifying Lists |
| 667 | @section Modifying Existing List Structure | 692 | @section Modifying Existing List Structure |
| 668 | @cindex destructive list operations | 693 | @cindex destructive list operations |
| @@ -1162,7 +1187,7 @@ compare @var{object} against the elements of the list. For example: | |||
| 1162 | This function destructively removes all elements @code{eq} to | 1187 | This function destructively removes all elements @code{eq} to |
| 1163 | @var{object} from @var{list}. The letter @samp{q} in @code{delq} says | 1188 | @var{object} from @var{list}. The letter @samp{q} in @code{delq} says |
| 1164 | that it uses @code{eq} to compare @var{object} against the elements of | 1189 | that it uses @code{eq} to compare @var{object} against the elements of |
| 1165 | the list, like @code{memq}. | 1190 | the list, like @code{memq} and @code{remq}. |
| 1166 | @end defun | 1191 | @end defun |
| 1167 | 1192 | ||
| 1168 | When @code{delq} deletes elements from the front of the list, it does so | 1193 | When @code{delq} deletes elements from the front of the list, it does so |
| @@ -1252,25 +1277,54 @@ Compare this with @code{memq}: | |||
| 1252 | @end example | 1277 | @end example |
| 1253 | @end defun | 1278 | @end defun |
| 1254 | 1279 | ||
| 1255 | @defun delete object list | 1280 | @defun delete object sequence |
| 1256 | This function destructively removes all elements @code{equal} to | 1281 | If @code{sequence} is a list, this function destructively removes all |
| 1257 | @var{object} from @var{list}. It is to @code{delq} as @code{member} is | 1282 | elements @code{equal} to @var{object} from @var{sequence}. For lists, |
| 1258 | to @code{memq}: it uses @code{equal} to compare elements with | 1283 | @code{delete} is to @code{delq} as @code{member} is to @code{memq}: it |
| 1259 | @var{object}, like @code{member}; when it finds an element that matches, | 1284 | uses @code{equal} to compare elements with @var{object}, like |
| 1260 | it removes the element just as @code{delq} would. For example: | 1285 | @code{member}; when it finds an element that matches, it removes the |
| 1286 | element just as @code{delq} would. | ||
| 1287 | |||
| 1288 | If @code{sequence} is a vector or string, @code{delete} returns a copy | ||
| 1289 | of @code{sequence} with all elements @code{equal} to @code{object} | ||
| 1290 | removed. | ||
| 1291 | |||
| 1292 | For example: | ||
| 1261 | 1293 | ||
| 1262 | @example | 1294 | @example |
| 1263 | @group | 1295 | @group |
| 1264 | (delete '(2) '((2) (1) (2))) | 1296 | (delete '(2) '((2) (1) (2))) |
| 1265 | @result{} ((1)) | 1297 | @result{} ((1)) |
| 1266 | @end group | 1298 | @end group |
| 1299 | @group | ||
| 1300 | (delete '(2) [(2) (1) (2)]) | ||
| 1301 | @result{} [(1)] | ||
| 1302 | @end group | ||
| 1303 | @end example | ||
| 1304 | @end defun | ||
| 1305 | |||
| 1306 | @defun remove object sequence | ||
| 1307 | This function is the non-destructive counterpart of @code{delete}. If | ||
| 1308 | returns a copy of @code{sequence}, a list, vector, or string, with | ||
| 1309 | elements @code{equal} to @code{object} removed. For example: | ||
| 1310 | |||
| 1311 | @example | ||
| 1312 | @group | ||
| 1313 | (remove '(2) '((2) (1) (2))) | ||
| 1314 | @result{} ((1)) | ||
| 1315 | @end group | ||
| 1316 | @group | ||
| 1317 | (remove '(2) [(2) (1) (2)]) | ||
| 1318 | @result{} [(1)] | ||
| 1319 | @end group | ||
| 1267 | @end example | 1320 | @end example |
| 1268 | @end defun | 1321 | @end defun |
| 1269 | 1322 | ||
| 1270 | @quotation | 1323 | @quotation |
| 1271 | @b{Common Lisp note:} The functions @code{member} and @code{delete} in | 1324 | @b{Common Lisp note:} The functions @code{member}, @code{delete} and |
| 1272 | GNU Emacs Lisp are derived from Maclisp, not Common Lisp. The Common | 1325 | @code{remove} in GNU Emacs Lisp are derived from Maclisp, not Common |
| 1273 | Lisp versions do not use @code{equal} to compare elements. | 1326 | Lisp. The Common Lisp versions do not use @code{equal} to compare |
| 1327 | elements. | ||
| 1274 | @end quotation | 1328 | @end quotation |
| 1275 | 1329 | ||
| 1276 | See also the function @code{add-to-list}, in @ref{Setting Variables}, | 1330 | See also the function @code{add-to-list}, in @ref{Setting Variables}, |