www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_167.html   search  
Buy the book!

Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.2 Save your time: dolist and dotimes

In addition to while, both dolist and dotimes provide for looping. Sometimes these are quicker to write than the equivalent while loop. Both are Lisp macros. (See section `Macros' in The GNU Emacs Lisp Reference Manual. )

dolist works like a while loop that `CDRs down a list': dolist automatically shortens the list each time it loops--takes the CDR of the list--and binds the CAR of each shorter version of the list to the first of its arguments.

dotimes loops a specific number of time: you specify the number.

The dolist Macro  
The dotimes Macro  

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003