[plt-scheme] Characters in a String

From: Dominique Boucher (dominique.boucher at nuecho.com)
Date: Thu May 27 21:30:01 EDT 2004

Connor, 

> Is there a way to split apart a string into its individual 
> characters? Sort of like doing the reverse of make-string. 
> The thing is, the string can be an arbitrary number of 
> characters so I can't really use substring. I'm trying to 
> find the spaces in a string and divide the string up into 
> individual words (which I can do with substring once I know 
> which characters are spaces). I need the characters either in 
> a list together or just a way to extract each character 
> individually in a recursive program (sort of like first and 
> rest with lists).

I think you are looking for string->list:

> (string->list "123")
(#\1 #\2 #\3)

It is a standard primitive Scheme procedure.

Dominique Boucher




Posted on the users mailing list.