string->sexpr

Synopsis

(string->sexpr string)

Parameters

  • string

Description

This procedure converts a string to a symbolic expression. If there are multiple SEXPRs contained in string, only the first one is returned. If the entire string is not a complete SEXPR, the EOF object is returned.

Side Effects

Return Value

A symbolic expression or the EOF object.

Implementation

(define (string->sexpr string)
 (with-input-from-string
   string
   (lambda () (read))))

Example

> (string->sexpr "100")
100
> (string->sexpr "(one (two (three)))")
(one (two (three)))
> (string->sexpr "(test")
#<end-of-file>
> (string->sexpr "(1 2 3) (this_is_ignored)")
(1 2 3)
>