|
From: | Stefan Monnier |
Subject: | Re: FW: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? |
Date: | Thu, 07 Jan 2021 22:36:20 -0500 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (times (length list))) > (dotimes (nr times new-list) > (let* ((item (elt list nr))) Please don't do that: such a "dotimes + elt" is fine when iterating over a *vector*, but when iterating over a list it means it'll take time O(n²) since `elt` on a list takes time O(n). So it's *much* better to use `dolist` (or `mapc` or ...) in that case. Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |