Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] stream conversion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dustin Sallings <dustin@s...>
Subject: Re: [Caml-list] stream conversion

On Dec 9, 2003, at 4:08, Remi Vanicat wrote:

> why do you use Stream.empty ? it would be more natural to use only
> Stream.next. As in :
> let stream_convert source =
>   let chunk = ref (Stream.of_string (Stream.next source)) in
>   Stream.from (fun x ->
>     try
>       Some (Stream.next !chunk)
>     with
>       Stream.Failure ->
>        (* code needed when the chunk is empty *)
>     )

	I think I considered that, but didn't explore that direction for some 
reason.  I'll give that a shot.  Overall, I'm looking for a bit less 
duplication.  It just seems like the whole thing should be smaller, so 
I assume there's a better way.

> By the way, your code make the assumption that no string in the source
> stream are empty (look at what would happen in such case).

	Well, I believe that I will have no empty streams in my use case, but 
that's no excuse.

	Thanks for the pointers.

-- 
Dustin Sallings

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners