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
String + 1
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Re: String + 1
Try this:
or ugglier:
Code: Select all
(concatenate 'string '(#\a #\b))
Code: Select all
(coerce '(#\a #\b) 'string)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.