(with-input-from-file "abc" (thunk (sequence->list (in-port))))

Note that you need to “read” in the dynamic extent of with-input-from-file.
Outside it, the port is closed.

On Fri, Jul 17, 2020 at 5:19 PM Hendrik Boom <[email protected]> wrote:

> Yes,  I know the functino for reading s-expressions seems to be (read
> [in]).
>
> I want a loop that reads S-expressions and does something to each one,
> until there are no more to be found in a file.
>
> Now of course that's absurdly easy to do with a tail-recursice loop.
>
> But I's like it to look like a loop, with (for ...) or (while ...) or
> (loop ...) or something like that.
>
> But I fail to fine any iterators that process a file, such as (in-file
> ...)
>
> There's a long list of iterators in
>    https://docs.racket-lang.org/reference/for.html
> and in
>    https://docs.racket-lang.org/guide/for.html
>
> An I just looking in the wrong place, or are there really no iterators
> for reading a stream of s-expressions from a file.
>
> -- hendrik
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200718001905.elzyuu42gje45j7t%40topoi.pooq.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvbps%3DtFJYg2UZ48s7uw1tVY8P58WnQYoZUMyShahCzhg%40mail.gmail.com.

Reply via email to