From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Understanding dotimes skipping by 2 Date: Thu, 27 Sep 2018 16:17:23 -0700 Message-ID: <87o9ciil8c.fsf@ericabrahamsen.net> References: <84a7o28rd8.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538090163 31043 195.159.176.226 (27 Sep 2018 23:16:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Sep 2018 23:16:03 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 28 01:15:59 2018 Return-path: Envelope-to: geh-help-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 1g5fVl-0007xK-3k for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Sep 2018 01:15:57 +0200 Original-Received: from localhost ([::1]:40245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5fXr-0004UM-KL for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Sep 2018 19:18:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5fXN-0004UH-Hb for help-gnu-emacs@gnu.org; Thu, 27 Sep 2018 19:17:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5fXK-0003Qn-Dy for help-gnu-emacs@gnu.org; Thu, 27 Sep 2018 19:17:37 -0400 Original-Received: from [195.159.176.226] (port=44532 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5fXK-0003QL-73 for help-gnu-emacs@gnu.org; Thu, 27 Sep 2018 19:17:34 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g5fVB-0007Q2-PV for help-gnu-emacs@gnu.org; Fri, 28 Sep 2018 01:15:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 28 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:v0o9mMl/IKwrwiY0v/jFQildXqQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118039 Archived-At: Marco Wahl writes: > Tim Johnson writes: > >> the following code snippet is as follows: >> (setq l `(1 2 3 4 5 6 7 8 9 0)) > >> ;; iterate through a list two elements at a time >> (let ((x 0)) >> (dotimes (/ (length l) 2) >> (progn >> (insert (format "%s %s, " (nth x l) (nth (+ x 1) l))) >> (setq x (+ x 2))))) >> >> ;; and below are the results >> 1 2, 3 4, 5 6, 7 8, 9 0, nil nil, nil nil, nil nil, nil nil, nil nil, 2 >> >> I'm confused about the output (nil etc...)which follow the expected numbers. >> could someone explain? >> P.S. I get the same output without the `progn form > > Looks like "/" is a variable which gets bound to the values of 0 up to > (length l) and the result of the loop is 2. > > It's in the documentation (C-h f dotimes). To add to that -- if you want to consume a loop two elements at a time, you'd be better off using `cl-loop' and its "by" keyword.