Josh
Josh

Reputation: 381

Is it possible to read a line as a list instead of a string?

I'm reading lines from a data file that are in list form. An example line is: ((P X1 (f X1)) (P Y (f b)))

Using read-line gives me a string which would require some tricky work to return to its original list form. I would like to avoid this work if possible.

Is there a simple way to read a line from a file as a list instead of as a string?

Upvotes: 0

Views: 37

Answers (1)

sds
sds

Reputation: 60054

If you already have a string, you can get the list out of it using read-from-string.

However, you can get the list right out of the input stream using read.

Upvotes: 3

Related Questions