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

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

[elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone


From: Thien-Thi Nguyen
Subject: [elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone
Date: Mon, 21 Apr 2014 21:32:09 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 9916db4253b268ddef7bc093f405e8c28000aea2
Author: Thien-Thi Nguyen <address@hidden>
Date:   Mon Apr 21 16:47:41 2014 +0200

    [gnugo int] Add abstraction: gnugo--mem-with-played-stone
    
    * packages/gnugo/gnugo.el (gnugo--mem-with-played-stone): New func.
    (gnugo--node-with-played-stone): Use it; convert to defsubst.
---
 packages/gnugo/gnugo.el |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 10e29e2..52aeb84 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1929,6 +1929,17 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
     (set-buffer-modified-p nil)
     (gnugo--who-is-who wait play samep)))
 
+(defun gnugo--mem-with-played-stone (pos)
+  (let ((color (case (following-char)
+                 (?X :B)
+                 (?O :W))))
+    (when color
+      (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
+            for mem on (aref (gnugo-get :monkey) 0)
+            when (equal fruit (caar mem))
+            return mem
+            finally return nil))))
+
 (defun gnugo-magic-undo (spec &optional noalt keep)
   "Undo moves on the GNUGO Board, based on SPEC, a string or number.
 If SPEC is a string in the form of a board position (e.g., \"T19\"),
@@ -2244,16 +2255,8 @@ which placed the stone at point."
   (gnugo-toggle-image-display)
   (save-excursion (gnugo-refresh)))
 
-(defun gnugo--node-with-played-stone (pos)
-  (let ((color (case (following-char)
-                 (?X :B)
-                 (?O :W))))
-    (when color
-      (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
-            for node in (aref (gnugo-get :monkey) 0)
-            if (equal fruit (car node))
-            return node
-            finally return nil))))
+(defsubst gnugo--node-with-played-stone (pos)
+  (car (gnugo--mem-with-played-stone pos)))
 
 (defun gnugo-describe-position ()
   "Display the board position under cursor in the echo area.



reply via email to

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