[Factor-talk] newbie question: how to collect info from a stream

2015-09-01 Thread HP Wei
I am just starting to learn factor.

In ocaml or python, when I open a file stream, I usually set up an object
with an accumulator class variable where I collect the selected info while 
walking through the stream (file).

I am trying to look at various places to find an equivalent way of doing this
[ or the natural way (folding?) of achieving the goal ] in factor.
Could you please help me out ?

thanks
HP
 

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] newbie question: how to collect info from a stream

2015-09-01 Thread Jon Harper
Hi,

Here's a simple example:
https://github.com/slavapestov/factor/blob/master/extra/tzinfo/tzinfo.factor

It uses with-file-reader (
http://docs.factorcode.org/content/word-with-file-reader,io.files.html ) to
bind the file stream to the default input stream. It then calls read and
its variants and when the whole file is parsed stores the result in an
object.

Regards,
Jon



Jon

On Tue, Sep 1, 2015 at 12:31 PM, HP Wei  wrote:

> I am just starting to learn factor.
>
> In ocaml or python, when I open a file stream, I usually set up an object
> with an accumulator class variable where I collect the selected info while
> walking through the stream (file).
>
> I am trying to look at various places to find an equivalent way of doing
> this
> [ or the natural way (folding?) of achieving the goal ] in factor.
> Could you please help me out ?
>
> thanks
> HP
>
>
>
> --
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk