Hello,

On May 19, 4:47 pm, Jay Fields <j...@jayfields.com> wrote:
> I'm not sure what the output should look like,

The fact that it is not obvious what the original code was supposed to
do indicates that it was not very readable...

Something like this would be much easier to understand (not very
compact, though):

(defn base-n-digits [base number]
  "returns a sequence of digits, least significant first"
  (loop [x number digits []]
    (if (zero? x)
      digits
      (recur (quot x base) (conj digits (rem x base))))))

(defn position2ascii [pos]
  (let [[col row] (base-n-digits 8 pos)]
    (str (nth "abcdefgh" col) (inc row))))

(defn move2ascii [move]
  (let [[to from] (base-n-digits 100 move)]
    (str (position2ascii from) (position2ascii to))))

Cheers,

Carlos

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to