Try file->string<div><br></div><div>Jay<br><br><div class="gmail_quote">On Mon, Dec 6, 2010 at 7:43 PM, prad <span dir="ltr"><<a href="mailto:prad@towardsfreedom.com">prad@towardsfreedom.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">i'm trying to read a text file into a string, sort of like<br>
<br>
readFile path -- in haskell<br>
or<br>
handle = open(path, 'r'); data = handle.read() # in python<br>
<br>
however, in the guide<br>
open-input-file<br>
call-with-input-file<br>
all use read-line<br>
<br>
in lisp i could get the length of the stream and slurp the whole file<br>
in:<br>
(defun slurp (path)<br>
"one way of reading in files"<br>
(with-open-file (stream path)<br>
(let ((seq (make-array (file-length stream)<br>
:element-type 'character)))<br>
(read-sequence seq stream)<br>
seq)))<br>
<br>
but what am i supposed to in racket?<br>
(other than read-line right through to the end of the file, may be?)<br>
<br>
or is reading it all in at one shot not considered the right way to do<br>
it here?<br>
<br>
--<br>
In friendship,<br>
prad<br>
<br>
... with you on your journey<br>
Towards Freedom<br>
<a href="http://www.towardsfreedom.com" target="_blank">http://www.towardsfreedom.com</a> (website)<br>
Information, Inspiration, Imagination - truly a site for soaring I's<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>"The glory of God is Intelligence" - D&C 93<br>
</div>