Created
October 26, 2011 14:43
-
-
Save mnzk/1316549 to your computer and use it in GitHub Desktop.
Excel A1 Converter 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn N->A [n] | |
(let [za "0ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
alen (dec (count za)) | |
iter (fn [[n xs]] [(int (/ n alen)) | |
(cons (nth za (rem n alen)), xs)])] | |
(->> (iterate iter [n '()]) | |
(drop-while (comp not zero? first)) | |
first second | |
(apply str)))) | |
(N->A 10000000000) ;=> "AFIPYQJP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment