emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnugo b484515 064/357: [gnugo int] Use ‘loop’, functio


From: Stefan Monnier
Subject: [elpa] externals/gnugo b484515 064/357: [gnugo int] Use ‘loop’, functional style more.
Date: Sun, 29 Nov 2020 14:50:49 -0500 (EST)

branch: externals/gnugo
commit b4845156eb14706336abe23182edd4c9eb24cb7b
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo int] Use ‘loop’, functional style more.
    
    * packages/gnugo/gnugo.el (gnugo-describe-internal-properties):
    ...here, for collecting/massaging ‘gnugo-state’,
    instead of ‘maphash’, "manual" destructuring, mutation.
---
 gnugo.el | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 0a4b345..917579c 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -247,24 +247,22 @@ Handle the big, slow-to-render, and/or uninteresting ones 
specially."
   (interactive)
   (let ((buf (current-buffer))
         (d (gnugo-get :diamond))
-        acc)
-    (maphash (lambda (&rest args)
-               (case (car args)
-                 ((:xpms :local-xpms)
-                  (setcdr args (format "hash: %X (%d images)"
-                                       (sxhash (cadr args))
-                                       (length (cadr args)))))
-                 (:sgf-collection
-                  (setcdr args (length (cadr args))))
-                 (:monkey
-                  (let* ((value (cadr args))
-                         (loc (aref value 0)))
-                    (setcdr args (list
-                                  (length (aref value 1))
-                                  (length (cdr loc))
-                                  (car loc))))))
-               (setq acc (cons args acc)))
-             gnugo-state)
+        (acc (loop for key being the hash-keys of gnugo-state
+                   using (hash-values val)
+                   collect (cons key
+                                 (case key
+                                   ((:xpms :local-xpms)
+                                    (format "hash: %X (%d images)"
+                                            (sxhash val)
+                                            (length val)))
+                                   (:sgf-collection
+                                    (length val))
+                                   (:monkey
+                                    (let ((loc (aref val 0)))
+                                      (list (length (aref val 1))
+                                            (length (cdr loc))
+                                            (car loc))))
+                                   (t val))))))
     (switch-to-buffer (get-buffer-create
                        (format "%s*GNUGO Board Properties*"
                                (gnugo-get :diamond))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]