Loops/Foreach: Difference between revisions

Content added Content deleted
(Emacs Lisp: Add cl-lib solution, remove obsolete info)
Line 1,146: Line 1,146:
'(1 2 3 4))</lang>
'(1 2 3 4))</lang>


{{libheader|cl-lib}}
<code>dolist</code> and <code>mapc</code> are both builtin in current Emacs. For past Emacs both can be had from <code>cl.el</code> with for instance <code>(eval-when-compile (require 'cl))</code>.


<lang Lisp>(cl-loop for x in '(1 2 3 4) do (message "x=%d" x))</lang>
<code>cl.el</code> also offers a <code>loop</code> macro similar in style to [[#Common Lisp|Common Lisp]].


=={{header|Erlang}}==
=={{header|Erlang}}==