From: Tino Calancha <f92capac@gmail.com>
To: 23550@debbugs.gnu.org
Subject: bug#23550: 25.0.93; cl.texi (for var on list by func): Fix documentation
Date: Tue, 17 May 2016 00:49:02 +0900 (JST) [thread overview]
Message-ID: <alpine.LRH.2.20.1605170046230.14791@calancha-ilc.kek.jp> (raw)
* doc/misc/cl.texi (for var on list by func): Fix documentation
'cl-loop for var on list by func' behaves as in CL: 'on' expression
need to be a list.
The following tests run in the *scratch* buffer return
same values as in SBCL:
;; CL cl-loop -> loop
emacs -Q:
(require 'cl-lib)
(setq preys '("grass" "lion" "rabbit"))
(defun next-prey (x)
"Return the name of the prey of animal X."
(cl-loop while (not (atom x))
do (setq x (car x)))
(cond ((member x preys) ; elisp
;; (cond ((member x preys :test #'string=) ; CL
(cond ((string= x "lion") "rabbit")
((string= x "rabbit") "grass")
(t nil)))
(t
nil)))
(defun next-prey-list (x)
"Return a list with the name of the prey of animal X."
(let ((res (next-prey x)))
(if res
(list res)
nil)))
[A] (mapcar 'next-prey '("grass" "lion" "rabbit"))
[B] (mapcar 'next-prey-list '("grass" "lion" "rabbit"))
[A] (nil "rabbit" "grass")
[B] (nil ("rabbit") ("grass"))
[I] (cl-loop for y on preys collect y)
[II] (cl-loop for y on preys by #'next-prey collect y)
[III] (cl-loop for y on (car preys) by #'next-prey collect y)
[IV] (cl-loop for y on (car preys) by #'next-prey-list collect y)
[V] (cl-loop for y on preys by #'next-prey-list collect y)
[I] (("grass" "lion" "rabbit") ("lion" "rabbit") ("rabbit"))
[II] (("grass" "lion" "rabbit"))
[III] nil
[IV] nil
[V] (("grass" "lion" "rabbit"))
In GNU Emacs 25.0.93.3 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
Repository revision: 6de0715f5467d4b925e2dfe082174529ace3b174
From 3e1756fb4d76e34b74b96782d4509582e9ce0cd3 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Tue, 17 May 2016 00:04:56 +0900
Subject: [PATCH] ; * cl.texi (clause 'for' with 'on'): Fix documentation
---
doc/misc/cl.texi | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 4137a95..319592c 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -1956,18 +1956,6 @@ For Clauses
@result{} ((1 2 3 4) (2 3 4) (3 4) (4))
@end example
-With @code{by}, there is no real reason that the @code{on} expression
-must be a list. For example:
-
-@example
-(cl-loop for x on first-animal by 'next-animal collect x)
-@end example
-
-@noindent
-where @code{(next-animal x)} takes an ``animal'' @var{x} and returns
-the next in the (assumed) sequence of animals, or @code{nil} if
-@var{x} was the last animal in the sequence.
-
@item for @var{var} in-ref @var{list} by @var{function}
This is like a regular @code{in} clause, but @var{var} becomes
a @code{setf}-able ``reference'' onto the elements of the list
--
2.8.1
next reply other threads:[~2016-05-16 15:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 15:49 Tino Calancha [this message]
2017-03-26 3:01 ` bug#23550: 25.0.93; cl.texi (for var on list by func): Fix documentation npostavs
2017-03-29 13:26 ` Tino Calancha
2017-03-29 14:08 ` npostavs
2017-03-31 8:20 ` Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LRH.2.20.1605170046230.14791@calancha-ilc.kek.jp \
--to=f92capac@gmail.com \
--cc=23550@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.