2007年5月11日星期五

String 運算簡介(1)

(defun nth-digit (digits i)
"The i-th element of a character string of digits, as an integer 0 to 9."
(- (char-code (char digits i)) #.(char-code #\0)))

這一串是代表什麼意思呢?
其實就是 digits[i]-'0' 的意思.

char-code 將字元轉成數值
char 取出字串中的字元
#\0 為 '0' 字元
#. 表示 reader 在 read 時就先做 read time evaluation

0 意見: