I've worked out how to read in the file and it works using the following code:
(define p (read(open-input-file "starbucks4.sxml")))
But how do i store p
as a list with elements separated by \n
characters.
Thanks.
I've worked out how to read in the file and it works using the following code:
(define p (read(open-input-file "starbucks4.sxml")))
But how do i store p
as a list with elements separated by \n
characters.
Thanks.
IIRC, both MIT Scheme and Racket, as far as some other implementations, have functions call-with-input-file
and call-with-output-file
. See this for details of their usage and this for complete reference.
As for a \n
separated list, the best approach I know is using Common Lisp style format
function. But if your implementation does't have such function, you will need to manually break your list and print it using write
function.
If you're using Racket (or PLT Scheme), you can use the read-line
function to read each line of the file to get them -- but they won't be read as s-exps, each will simply be a string.