unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: npostavs@users.sourceforge.net
Cc: Tino Calancha <f92capac@gmail.com>, 23550@debbugs.gnu.org
Subject: bug#23550: 25.0.93; cl.texi (for var on list by func): Fix documentation
Date: Wed, 29 Mar 2017 22:26:27 +0900	[thread overview]
Message-ID: <87lgroxlh8.fsf@calancha-pc> (raw)
In-Reply-To: <874lyg68rq.fsf@users.sourceforge.net> (npostavs's message of "Sat, 25 Mar 2017 23:01:45 -0400")

npostavs@users.sourceforge.net writes:

>>
>> 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)))
>
> I guess the idea behind that statement is that the rest of the list can
> be implied by the stepping function, e.g.
>
>     (cl-loop for y on (list "lion") by #'next-prey-list collect (car y))
>       ;=> ("lion" "rabbit" "grass")
>
> Works with the "in" clause too:
>
>     (cl-loop for y in (list "lion") by #'next-prey-list collect y)
>       ;=> ("lion" "rabbit" "grass")
>
> I guess it could be useful in combination with streams?  Not sure if
> it's worth having this in the manual.
In the way is written makes me expect that:
(cl-loop for y on "lion" by #'next-prey-list collect (car y))

will be evaluated to: ("lion" "rabbit" "grass").

Becase i read in the example first-animal, instead of (list first-animal), 
and they also write:
'With @code{by}, there is no real reason that the @code{on} expression
must be a list.'

It might be useful rewrite that part to make it more clear, but i don't
have a clear proposal.






  reply	other threads:[~2017-03-29 13:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 15:49 bug#23550: 25.0.93; cl.texi (for var on list by func): Fix documentation Tino Calancha
2017-03-26  3:01 ` npostavs
2017-03-29 13:26   ` Tino Calancha [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgroxlh8.fsf@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=23550@debbugs.gnu.org \
    --cc=f92capac@gmail.com \
    --cc=npostavs@users.sourceforge.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).