[plt-scheme] Characters in a String

From: Win Treese (treese at acm.org)
Date: Thu May 27 22:46:38 EDT 2004

> 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).

Connor,

Would:

    (require (lib "string.ss"))
    (regexp-split " +" "a b cde fg d")
    => ("a" "b" "cde" "fg" "d")

be an easier solution? regexp-split is in the string library, documented
in http://download.plt-scheme.org/doc/205/html/mzlib/mzlib-Z-H-34.html

   - Win





Posted on the users mailing list.