I'm having a bit of an issue taking a text file and converting it into a list or string.
Say I have "blah.txt" which holds:
3 + 4
Now I want to call that file which I know can be done by
(define in (open-input-file "blah.txt"))
Where do I take it from here?
Given a file name, file->string loads the file and returns the content as a string.
Take a look at the file->list
function or file->lines
, which should do what you want in Racket. That is, something like (file->lines "blah.txt")
will give you a list of lines from the file. More generally, look at the guide entry on I/O.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With