|
From: | Jean Louis |
Subject: | Re: FW: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? |
Date: | Fri, 8 Jan 2021 05:50:25 +0300 |
User-agent: | Mutt/2.0 (3d08634) (2020-11-07) |
When replacing `dotimes' I also discover some of my errors: (defun list-append-first-to-first-cons (list) "Cons with FIRST-ELT . FIRST-ELT" (let ((new-list '()) (times (length list))) (dotimes (nr times new-list) (let* ((item (elt list nr))) (push (cons item item) new-list))))) (list-append-first-to-first-cons '(1 2 3)) ((3 . 3) (2 . 2) (1 . 1)) Then I replace it like: (defun list-append-first-to-first-cons (list) "Cons with FIRST-ELT . FIRST-ELT" (mapcar (lambda (item) (cons item item)) list)) (list-append-first-to-first-cons '(1 2 3)) ((1 . 1) (2 . 2) (3 . 3)) The reverse order was not detectable as results were used always in completion lists and I have not ever put attention on the order. In general I can replace `dotimes' without return value with `while' and those that shall return values as sequences with mapping functions.
[Prev in Thread] | Current Thread | [Next in Thread] |