[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 35/255: compiled and caught some minor issues
From: |
Eric Schulte |
Subject: |
[elpa] 35/255: compiled and caught some minor issues |
Date: |
Sun, 16 Mar 2014 01:02:14 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit a54a935f96ce7a277638cafadb7e3137fb19bc43
Author: Eric Schulte <address@hidden>
Date: Thu May 17 15:40:58 2012 -0400
compiled and caught some minor issues
---
.gitignore | 1 +
sgf.el | 48 ++++++++++++++++++------------------------------
2 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8fce603..dff379c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
data/
+*.elc
diff --git a/sgf.el b/sgf.el
index 575e47c..011e9eb 100644
--- a/sgf.el
+++ b/sgf.el
@@ -81,17 +81,6 @@
;;; Utility
-(defun some (seq comb &optional func)
- (flet ((this (el) (funcall (or func #'identity) el)))
- (reduce (lambda (acc el)
- (case comb
- (:or (or acc (this el)))
- (:and (and acc (this el)))))
- seq :initial-value (case comb (:or nil) (:and t)))))
-
-(defun any (seq &optional func) (some seq :or func))
-(defun all (seq &optional func) (some seq :and func))
-
(defun aget (key list) (cdr (assoc key list)))
(defun range (a &optional b)
@@ -341,7 +330,8 @@
(setf *index* '(0))
(push (cons :pieces (board-to-pieces *board*))
(sgf-ref *sgf* *index*))
- (update-display))
+ (update-display)
+ (assert (tree-equal *index* '(0)) 'show-args))
(pop-to-buffer buffer)))
(defun sgf-ref (sgf index)
@@ -352,10 +342,8 @@
part))
(defun set-sgf-ref (sgf index new)
- (eval `(setf ,(if (listp index)
- (reduce (lambda (acc el) (list 'nth el acc))
- index :initial-value 'sgf)
- `(nth ,accessor 'sgf))
+ (eval `(setf ,(reduce (lambda (acc el) (list 'nth el acc))
+ index :initial-value 'sgf)
',new)))
(defsetf sgf-ref set-sgf-ref)
@@ -402,23 +390,23 @@
((member (car move) '("LB" "LW")) :label)))
(defun apply-moves (board moves)
- (flet ((set (val data)
- (setf (aref board (pos-to-index (aget :pos data)
- (board-size board)))
- (cond ((string= "B" val) :b)
- ((string= "W" val) :w)
- ((string= "LB" val) (aget :label data))
- ((string= "LW" val) (aget :label data))
- (t nil)))))
+ (flet ((bset (val data)
+ (setf (aref board (pos-to-index (aget :pos data)
+ (board-size board)))
+ (cond ((string= "B" val) :b)
+ ((string= "W" val) :w)
+ ((string= "LB" val) (aget :label data))
+ ((string= "LW" val) (aget :label data))
+ (t nil)))))
(dolist (move moves board)
(case (move-type move)
(:move
- (set (car move) (cdr move))
+ (bset (car move) (cdr move))
(let ((color (if (string= "B" (car move)) :b :w)))
(remove-dead *board* (other-color color))
(remove-dead *board* color)))
(:label
- (mapcar (lambda (data) (set (car move) data)) (cdr move)))))))
+ (dolist (data (cdr move)) (bset (car move) data)))))))
(defun clear-labels (board)
(dotimes (point (length board))
@@ -450,10 +438,10 @@
(when (equal v val) n))
neighbors neighbor-vals)))
(already (cons piece (append friendly-neighbors already))))
- (or (any neighbor-vals ; touching open space
- (lambda (v) (not (equal v enemy))))
- (any friendly-neighbors ; touching alive dragon
- (lambda (n) (alive-p board n already))))))
+ (or (some (lambda (v) (not (equal v enemy))) ; touching open space
+ neighbor-vals)
+ (some (lambda (n) (alive-p board n already)) ; touching alive dragon
+ friendly-neighbors))))
(defun remove-dead (board color)
;; must remove one color at a time for ko situations
- [elpa] 10/255: helper functions, (continued)
- [elpa] 10/255: helper functions, Eric Schulte, 2014/03/15
- [elpa] 24/255: right and left implemented but buggy, Eric Schulte, 2014/03/15
- [elpa] 23/255: more complex but more intuitive and useful `range', Eric Schulte, 2014/03/15
- [elpa] 21/255: display sgf file as a go board in a buffer, Eric Schulte, 2014/03/15
- [elpa] 25/255: right and left are mainly working, Eric Schulte, 2014/03/15
- [elpa] 29/255: q now quits a sgf display buffer, Eric Schulte, 2014/03/15
- [elpa] 28/255: adding a major mode for board navigation keys, Eric Schulte, 2014/03/15
- [elpa] 27/255: implementation notes, Eric Schulte, 2014/03/15
- [elpa] 31/255: a test to protect against unwanted state changes, Eric Schulte, 2014/03/15
- [elpa] 33/255: removing dead pieces after moves, Eric Schulte, 2014/03/15
- [elpa] 35/255: compiled and caught some minor issues,
Eric Schulte <=
- [elpa] 32/255: consolidating utility functions, Eric Schulte, 2014/03/15
- [elpa] 30/255: saving the board configuration with each sgf step, Eric Schulte, 2014/03/15
- [elpa] 18/255: applying moves to a board, Eric Schulte, 2014/03/15
- [elpa] 37/255: remove debug printf, Eric Schulte, 2014/03/15
- [elpa] 34/255: beginning to stub out tests for dead stone removal, Eric Schulte, 2014/03/15
- [elpa] 38/255: more capture tests, failing multistone captures, Eric Schulte, 2014/03/15
- [elpa] 36/255: passing all tests (at least it did this once), Eric Schulte, 2014/03/15
- [elpa] 26/255: improvements, considering labels and moves, Eric Schulte, 2014/03/15
- [elpa] 40/255: parsing empty properties, Eric Schulte, 2014/03/15
- [elpa] 42/255: more work with tree parsing, Eric Schulte, 2014/03/15