[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 132/255: moving char-to-num and num-to-char to util
From: |
Eric Schulte |
Subject: |
[elpa] 132/255: moving char-to-num and num-to-char to util |
Date: |
Sun, 16 Mar 2014 01:02:34 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 848ea6d1e1dc481f6186b1f505bc21649d3a5bbf
Author: Eric Schulte <address@hidden>
Date: Thu May 31 23:46:29 2012 -0600
moving char-to-num and num-to-char to util
these will later need to be renamed
---
back-ends/gtp.el | 22 ++--------------------
back-ends/sgf2el.el | 17 ++++++++---------
go-util.el | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/back-ends/gtp.el b/back-ends/gtp.el
index 42566f4..425107c 100644
--- a/back-ends/gtp.el
+++ b/back-ends/gtp.el
@@ -40,29 +40,11 @@
(:W "white")
(t (error "gtp: unknown turn %S" turn))))
-(defun gtp-char-to-num (char)
- (flet ((err () (error "gtp: invalid char %s" char)))
- (cond
- ((< char ?A) (err))
- ((< char ?I) (- char ?A))
- ((<= char ?T) (1- (- char ?A)))
- ((< char ?a) (err))
- ((< char ?i) (- char ?a))
- ((<= char ?t) (1- (- char ?a)))
- (t (err)))))
-
-(defun gtp-num-to-char (num)
- (flet ((err () (error "gtp: invalid num %s" num)))
- (cond
- ((< num 1) (err))
- ((< num 9) (+ ?A (1- num)))
- (t (+ ?A num)))))
-
(defun go-pos-to-gtp (pos)
- (format "%c%d" (gtp-num-to-char (1+ (car pos))) (1+ (cdr pos))))
+ (format "%c%d" (num-to-char (1+ (car pos))) (1+ (cdr pos))))
(defun gtp-to-pos (color gtp)
- (cons color (cons :pos (cons (gtp-char-to-num (aref gtp 0))
+ (cons color (cons :pos (cons (char-to-num (aref gtp 0))
(1- (read (substring gtp 1)))))))
(defun go-to-gtp-command (element)
diff --git a/back-ends/sgf2el.el b/back-ends/sgf2el.el
index b18bd0f..a4fc122 100644
--- a/back-ends/sgf2el.el
+++ b/back-ends/sgf2el.el
@@ -149,16 +149,15 @@
(car date-args)))))
(add-to-list 'sgf2el-special-properties (cons :DT #'process-date))
-(defun char-to-num (char)
- (cond
- ((or (< char ?A) (< ?z char))
- (error "sgf: invalid char %s" char))
- ((< char ?a) (+ 26 (- char ?A)))
- (t (- char ?a))))
-
(defun process-position (position-string)
- (cons (char-to-num (aref position-string 0))
- (char-to-num (aref position-string 1))))
+ (flet ((char-to-num (char)
+ (cond
+ ((or (< char ?A) (< ?z char))
+ (error "sgf: invalid char %s" char))
+ ((< char ?a) (+ 26 (- char ?A)))
+ (t (- char ?a)))))
+ (cons (char-to-num (aref position-string 0))
+ (char-to-num (aref position-string 1)))))
(defun process-move (move-args)
(list (cons :pos (process-position (car move-args)))))
diff --git a/go-util.el b/go-util.el
index deb5b6a..d248d55 100644
--- a/go-util.el
+++ b/go-util.el
@@ -72,4 +72,22 @@
(defun ear-muffs (str) (concat "*" str "*"))
+(defun char-to-num (char)
+ (flet ((err () (error "gtp: invalid char %s" char)))
+ (cond
+ ((< char ?A) (err))
+ ((< char ?I) (- char ?A))
+ ((<= char ?T) (1- (- char ?A)))
+ ((< char ?a) (err))
+ ((< char ?i) (- char ?a))
+ ((<= char ?t) (1- (- char ?a)))
+ (t (err)))))
+
+(defun num-to-char (num)
+ (flet ((err () (error "gtp: invalid num %s" num)))
+ (cond
+ ((< num 1) (err))
+ ((< num 9) (+ ?A (1- num)))
+ (t (+ ?A num)))))
+
(provide 'go-util)
- [elpa] 125/255: removed dependency on `parse-integer', (continued)
- [elpa] 125/255: removed dependency on `parse-integer', Eric Schulte, 2014/03/15
- [elpa] 126/255: sketching out passing, Eric Schulte, 2014/03/15
- [elpa] 124/255: highlighting last move and added pass function, Eric Schulte, 2014/03/15
- [elpa] 123/255: working towards savings games in SGF format, Eric Schulte, 2014/03/15
- [elpa] 127/255: documentation tweaks, Eric Schulte, 2014/03/15
- [elpa] 129/255: igs message types from igs.c, Eric Schulte, 2014/03/15
- [elpa] 118/255: cleanup in go.el, Eric Schulte, 2014/03/15
- [elpa] 130/255: adding a file for tracking development notes, Eric Schulte, 2014/03/15
- [elpa] 128/255: starting to flesh out igs support, Eric Schulte, 2014/03/15
- [elpa] 119/255: test cleanup, Eric Schulte, 2014/03/15
- [elpa] 132/255: moving char-to-num and num-to-char to util,
Eric Schulte <=
- [elpa] 115/255: uniform gnugo prefix, Eric Schulte, 2014/03/15
- [elpa] 134/255: notes, Eric Schulte, 2014/03/15
- [elpa] 131/255: transitioning IGS interface to use client mode, Eric Schulte, 2014/03/15
- [elpa] 140/255: board propagates setf'd moves to trackers, Eric Schulte, 2014/03/15
- [elpa] 137/255: setf method for aget, Eric Schulte, 2014/03/15
- [elpa] 133/255: igs using a process filter for asynch processing, Eric Schulte, 2014/03/15
- [elpa] 136/255: two small fixes, Eric Schulte, 2014/03/15
- [elpa] 135/255: stubbed out API interface for go-board, Eric Schulte, 2014/03/15
- [elpa] 139/255: fixed off-by-one in igs moves & tracking last move, Eric Schulte, 2014/03/15
- [elpa] 138/255: igs can track a current game and apply moves, Eric Schulte, 2014/03/15