Split string into separate characters

I am having two problems while working in Lisp, and I cannot find any tutorials or sites that will explain this. How do you split a string into separate characters? And how can I change these characters to their corresponding ASCII values? If anyone knows any sites or training videos explaining them, they will be very grateful.

+5
source share
4 answers
CL-USER 87 > (coerce "abc" 'list)
(#\a #\b #\c)


CL-USER 88 > (map 'list #'char-code "abc")
(97 98 99)

Get Generic Lisp Short Description .

+9
source

A Lisp . , , , , (, ) .

+1

split-string ; , . omit-nulls nil ( ), , , . omit-nulls t, . nil ( ), - .

, nil ( ), . :

(split-string " two words ") -> ("two" "words")
The result is not ("" "two" "words" ""), which would rarely be useful. If you need
such a result, use an explicit value for separators:
(split-string " two words " split-string-default-separators)  -> ("" "two" "words" "")

More examples:
(split-string "Soup is good food" "o")   ->   ("S" "up is g" "" "d f" "" "d")
(split-string "Soup is good food" "o" t) -> ("S" "up is g" "d f" "d")
(split-string "Soup is good food" "o+")  ->  ("S" "up is g" "d f" "d")
0
source

You can also use elt or aref to get specific characters from a string.

One of the best sites for an in-depth introduction to Common Lisp is the Practical General Lisp book site ( link to a section on numbers, characters, and strings ). The entire book is available online for free. Check this.

0
source

All Articles