all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Understanding dotimes skipping by 2
@ 2018-09-27 22:48 Tim Johnson
  2018-09-28  1:29 ` Van L
  0 siblings, 1 reply; 13+ messages in thread
From: Tim Johnson @ 2018-09-27 22:48 UTC (permalink / raw)
  To: Emacs

using GNU Emacs 26.1 (GTK+ Version) on ubuntu 14.04
 
the following code snippet is as follows:
(setq l `(1 2 3 4 5 6 7 8 9 0))
(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
thanks
-- 
Tim Johnson
http://www.tj49.com



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-09-28 18:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1418.1538089091.1284.help-gnu-emacs@gnu.org>
2018-09-27 23:14 ` Understanding dotimes skipping by 2 Marco Wahl
2018-09-27 23:17   ` Eric Abrahamsen
2018-09-27 23:59     ` Tim Johnson
2018-09-27 23:32   ` Tim Johnson
2018-09-27 22:48 Tim Johnson
2018-09-28  1:29 ` Van L
2018-09-28  2:56   ` Tim Johnson
2018-09-28  9:11   ` Joost Kremers
2018-09-28  9:50     ` Van L
2018-09-28 12:23       ` Eli Zaretskii
2018-09-28 12:26         ` Van L
2018-09-28 17:47     ` Tim Johnson
2018-09-28 18:16     ` Noam Postavsky

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.