From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#23550: 25.0.93; cl.texi (for var on list by func): Fix documentation Date: Sat, 25 Mar 2017 23:01:45 -0400 Message-ID: <874lyg68rq.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1490497277 17080 195.159.176.226 (26 Mar 2017 03:01:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Mar 2017 03:01:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 23550@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 26 05:01:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cryQV-0003Ug-37 for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Mar 2017 05:01:07 +0200 Original-Received: from localhost ([::1]:39404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cryQb-0003nI-8t for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Mar 2017 23:01:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cryQT-0003nC-I2 for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2017 23:01:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cryQQ-000251-Gj for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2017 23:01:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cryQQ-00024J-5L for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2017 23:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cryQP-0007ob-Pr for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2017 23:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Mar 2017 03:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23550 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 23550-submit@debbugs.gnu.org id=B23550.149049723029990 (code B ref 23550); Sun, 26 Mar 2017 03:01:01 +0000 Original-Received: (at 23550) by debbugs.gnu.org; 26 Mar 2017 03:00:30 +0000 Original-Received: from localhost ([127.0.0.1]:44860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cryPu-0007ne-2U for submit@debbugs.gnu.org; Sat, 25 Mar 2017 23:00:30 -0400 Original-Received: from mail-it0-f42.google.com ([209.85.214.42]:37463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cryPs-0007nP-Ov for 23550@debbugs.gnu.org; Sat, 25 Mar 2017 23:00:29 -0400 Original-Received: by mail-it0-f42.google.com with SMTP id 190so23335694itm.0 for <23550@debbugs.gnu.org>; Sat, 25 Mar 2017 20:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=oOr1UNvd+hqb+Gq7DFHKm+OMawuPbUIDe6TxKdgtJWQ=; b=kvKskmNEsuOV6xn7EZqhoscnhHQhSQvrk4f25agNQqxbXSCmgtKaNf8bh7Mwv2hMbX gaMt/9xhK+Pxvihm84TZHv4DP5D64L56tdFXIghr1SWIv/cdPjigCp9rw4QetnF4Asra Kvcff3laC6BabhMNtD2BNtFTVHbcI7aQVsCxWgutAloxmU/pwc8SXJd+cRJJ6niGonTb Rc988cbvj1J8YJE5bgYm7cJJgkZ3BogdLcjUHRRP+tPZwOuNpUMCNSuSQDu6o7akVBAk E2nVHAgOof1v/GSWYmxEmSkyK5jald8QWymrJn4G8ACR8bIUaP9c/K0FfwnlBgMHNw4Q IQTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=oOr1UNvd+hqb+Gq7DFHKm+OMawuPbUIDe6TxKdgtJWQ=; b=nuj95IJUuOsMOzyV4IQz+z2QPCFGlUn87ps74Ii1MlRJ41VnggQ1VX4n0mubFAaoph Siybd5VdeFVxXssDCIWYJ9iEl+ty3T5mNDc4Ekugl7sTcG9k2eBGXQR8mhroC1A/RA5B TMsa3MPsdjkrKAnmhFrDER0qIc+6YHNjdX0TxvjyN1Wo4xwfBwImFCQdfIxaql5/Do2D vVSyoqco7L25YTnle6Q7qdUpPxb3ZMvbZhaJemcMrp6cEJjG2HOz3mky7LnMjW8fEq0G t3GQKW7SBJOTKdl35qesagB5tV/I1ozkcMFAbccy0jvm3CbeAG+WLby+ViEKDQKV5b4Z XI2g== X-Gm-Message-State: AFeK/H0c0CRHd748KVt+T4YutCKsEygvfn12jeafVCoeQ94elyU43uirlVljAdAItk66fQ== X-Received: by 10.107.129.214 with SMTP id l83mr14874791ioi.168.1490497222966; Sat, 25 Mar 2017 20:00:22 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id p6sm3585592iof.12.2017.03.25.20.00.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Mar 2017 20:00:22 -0700 (PDT) In-Reply-To: (Tino Calancha's message of "Tue, 17 May 2016 00:49:02 +0900 (JST)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130965 Archived-At: Tino Calancha writes: > * 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. Well, it only needs to be a cons, because that's what the loop checks for. > > 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.