|
From: | Jean Louis |
Subject: | How to get plist properties list? |
Date: | Fri, 8 Jan 2021 07:48:46 +0300 |
User-agent: | Mutt/2.0 (3d08634) (2020-11-07) |
As I am replacing here `dotimes': (setq plist '(age "47" name "Doe")) (defun divisible-by-2-or-0-p (n) "Returns t if number is divisible by 2" (if (or (= n 0) (= (/ n 2.0) (truncate (/ n 2.0)))) t nil)) (defun plist-properties (plist) "Returns plist properties" (let* ((length (length plist)) (properties '())) (dotimes (i length (reverse properties)) (if (divisible-by-2-or-0-p i) (push (elt plist i) properties))))) instead of the above complications to extreme length, I have replaced it with this one below: (defun plist-properties (plist) (let ((n 0) (properties '())) (while (/= n (length plist)) (push (elt plist n) properties) (setq n (+ 2 n))) properties)) But maybe there is some more simpler way to get plist properties list? Jean
[Prev in Thread] | Current Thread | [Next in Thread] |