racket – Scheme: number to string, string to list

racket – Scheme: number to string, string to list

The preceding # is scheme syntax for a character. You can convert each character to a number by first making it a string, then using string->number:

(number? (string->number (string #1)))
=> #t

You can compose these two procedures, and map them onto your list as follows:

(map (compose string->number string)
     (string->list (number->string 1234)))
=> (1 2 3 4)

racket – Scheme: number to string, string to list

Leave a Reply

Your email address will not be published.