[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Virtual pet for Emacs
From: |
Emanuel Berg |
Subject: |
Re: Virtual pet for Emacs |
Date: |
Thu, 05 May 2022 05:47:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
>>> (defun points-to-evolution (total-points)
>>> (dolist (points +pet-evolution-tree+)
>>> (if (> (car points) total-points)
>>> (return ;; <------------------- HERE
>>> (nth 1
>>> (assoc (car points) +pet-evolution-tree+))))))
>>
>> That should be `cl-dolist` and `cl-return`.
>
> Oh, so that's the intention, then rather than that use
> a list (higher-order) function!
That code has a lot of things that can be improved,
- get away with `cl-return', use for example `cl-find-if'
instead
- don't do (car points) twice
- don't search the list twice (first `cl-dolist', then
`assoc')
- better names: if "points" are extracted from the
pet-evolution (remove the CL naming conventions with plus
signs around a constant; also there is no reason to say what
data structure a data structure is in its name, cmp.
`user-full-name' not "user-full-name-string")
I actually think all or almost all will be fixed if the first
issue is fixed ...
--
underground experts united
https://dataswamp.org/~incal
- Re: Virtual pet for Emacs, (continued)