Page 1 of 1

String + 1

Posted: Sat Jul 14, 2012 2:16 am
by Ehsan
Hi everyone . i need to write a function in lisp that receive string and then add 1 to each characters. for example "2a6c12" and then return "3b7d23".

i write this function

(defun my-list(f)
(loop for x across f collect(code-char(+ 1 (char-code x)))))

but my output like this (#\3 #\b #\7 #\d #\2 #\3) . how can i change this output to normal form ("3b7d23")


tnx a lot

Re: String + 1

Posted: Sat Jul 14, 2012 2:52 am
by Goheeca
Try this:

Code: Select all

(concatenate 'string '(#\a #\b))
or ugglier:

Code: Select all

(coerce '(#\a #\b) 'string)