diff options
| author | Richard M. Stallman | 2007-04-14 12:38:06 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2007-04-14 12:38:06 +0000 |
| commit | 31fd7ef864ab812441b0a18472ea7a5756412cd9 (patch) | |
| tree | 4e065a8a34e371940f6cc227e899c6b9e429b898 | |
| parent | e47b701926d690e6a4e6a686656f7c9aafd4b055 (diff) | |
| download | emacs-31fd7ef864ab812441b0a18472ea7a5756412cd9.tar.gz emacs-31fd7ef864ab812441b0a18472ea7a5756412cd9.zip | |
(Sets And Lists): Clarify `delete' examples.
Remove spurious xref to same node.
Clarify xref for add-to-list.
| -rw-r--r-- | lispref/lists.texi | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi index 53fe64c3cc6..f7c56d7f8a4 100644 --- a/lispref/lists.texi +++ b/lispref/lists.texi | |||
| @@ -1366,6 +1366,9 @@ and the @code{(4)} in the @code{sample-list} are not @code{eq}: | |||
| 1366 | (delq '(4) sample-list) | 1366 | (delq '(4) sample-list) |
| 1367 | @result{} (a c (4)) | 1367 | @result{} (a c (4)) |
| 1368 | @end group | 1368 | @end group |
| 1369 | |||
| 1370 | If you want to delete elements that are @code{equal} to a given value, | ||
| 1371 | use @code{delete} (see below). | ||
| 1369 | @end example | 1372 | @end example |
| 1370 | 1373 | ||
| 1371 | @defun remq object list | 1374 | @defun remq object list |
| @@ -1388,9 +1391,6 @@ sample-list | |||
| 1388 | @result{} (a b c a b c) | 1391 | @result{} (a b c a b c) |
| 1389 | @end group | 1392 | @end group |
| 1390 | @end example | 1393 | @end example |
| 1391 | @noindent | ||
| 1392 | The function @code{delq} offers a way to perform this operation | ||
| 1393 | destructively. See @ref{Sets And Lists}. | ||
| 1394 | @end defun | 1394 | @end defun |
| 1395 | 1395 | ||
| 1396 | @defun memql object list | 1396 | @defun memql object list |
| @@ -1448,8 +1448,8 @@ If @code{sequence} is a list, this function destructively removes all | |||
| 1448 | elements @code{equal} to @var{object} from @var{sequence}. For lists, | 1448 | elements @code{equal} to @var{object} from @var{sequence}. For lists, |
| 1449 | @code{delete} is to @code{delq} as @code{member} is to @code{memq}: it | 1449 | @code{delete} is to @code{delq} as @code{member} is to @code{memq}: it |
| 1450 | uses @code{equal} to compare elements with @var{object}, like | 1450 | uses @code{equal} to compare elements with @var{object}, like |
| 1451 | @code{member}; when it finds an element that matches, it removes the | 1451 | @code{member}; when it finds an element that matches, it cuts the |
| 1452 | element just as @code{delq} would. | 1452 | element out just as @code{delq} would. |
| 1453 | 1453 | ||
| 1454 | If @code{sequence} is a vector or string, @code{delete} returns a copy | 1454 | If @code{sequence} is a vector or string, @code{delete} returns a copy |
| 1455 | of @code{sequence} with all elements @code{equal} to @code{object} | 1455 | of @code{sequence} with all elements @code{equal} to @code{object} |
| @@ -1459,8 +1459,22 @@ For example: | |||
| 1459 | 1459 | ||
| 1460 | @example | 1460 | @example |
| 1461 | @group | 1461 | @group |
| 1462 | (delete '(2) '((2) (1) (2))) | 1462 | (setq l '((2) (1) (2))) |
| 1463 | (delete '(2) l) | ||
| 1463 | @result{} ((1)) | 1464 | @result{} ((1)) |
| 1465 | l | ||
| 1466 | @result{} ((2) (1)) | ||
| 1467 | ;; @r{If you want to change @code{l} reliably,} | ||
| 1468 | ;; @r{write @code{(setq l (delete elt l))}.} | ||
| 1469 | @end group | ||
| 1470 | @group | ||
| 1471 | (setq l '((2) (1) (2))) | ||
| 1472 | (delete '(1) l) | ||
| 1473 | @result{} ((2) (2)) | ||
| 1474 | l | ||
| 1475 | @result{} ((2) (2)) | ||
| 1476 | ;; @r{In this case, it makes no difference whether you set @code{l},} | ||
| 1477 | ;; @r{but you should do so for the sake of the other case.} | ||
| 1464 | @end group | 1478 | @end group |
| 1465 | @group | 1479 | @group |
| 1466 | (delete '(2) [(2) (1) (2)]) | 1480 | (delete '(2) [(2) (1) (2)]) |
| @@ -1470,7 +1484,7 @@ For example: | |||
| 1470 | @end defun | 1484 | @end defun |
| 1471 | 1485 | ||
| 1472 | @defun remove object sequence | 1486 | @defun remove object sequence |
| 1473 | This function is the non-destructive counterpart of @code{delete}. If | 1487 | This function is the non-destructive counterpart of @code{delete}. It |
| 1474 | returns a copy of @code{sequence}, a list, vector, or string, with | 1488 | returns a copy of @code{sequence}, a list, vector, or string, with |
| 1475 | elements @code{equal} to @code{object} removed. For example: | 1489 | elements @code{equal} to @code{object} removed. For example: |
| 1476 | 1490 | ||
| @@ -1509,7 +1523,8 @@ several @code{equal} occurrences of an element in @var{list}, | |||
| 1509 | @end defun | 1523 | @end defun |
| 1510 | 1524 | ||
| 1511 | See also the function @code{add-to-list}, in @ref{List Variables}, | 1525 | See also the function @code{add-to-list}, in @ref{List Variables}, |
| 1512 | for another way to add an element to a list stored in a variable. | 1526 | for a way to an element to a list stored in a variable and used as a |
| 1527 | set. | ||
| 1513 | 1528 | ||
| 1514 | @node Association Lists | 1529 | @node Association Lists |
| 1515 | @section Association Lists | 1530 | @section Association Lists |