Thank you for the package! So, do I understand correcty that it is
impossible to produce multi-valued streams with for/stream? If so, maybe
it's worth adding a note about it to the documentation of for/stream?

Also, I notice in the manual of your package that you mention that
generators are inefficient in the default implementation of
Racket. Since I'm using generators too, I'm curious about the
performance implications - where can I read more about it?

Best,
--
Yury Bulka
https://mamot.fr/@setthemfree
#NotOnFacebook



Sorawee Porncharoenwase <sorawee.pw...@gmail.com> writes:

> I just created a package that helps creating a stream of multiple values a
> couple of weeks ago. You might find it useful:
> https://docs.racket-lang.org/stream-values/
>
> On Sat, May 2, 2020 at 3:38 PM Yury Bulka <setthemf...@privacyrequired.com>
> wrote:
>
>> (sorry for the typos - obviously, it should be racket/stream)
>>
>> --
>> Yury Bulka
>> https://mamot.fr/@setthemfree
>> #NotOnFacebook
>>
>>
>>
>> Yury Bulka <setthemf...@privacyrequired.com> writes:
>>
>> > Hello everyone,
>> >
>> > I have a question about creating a steam that yields multiple values on
>> > each iteration. Given something like:
>> >
>> > (require racket/strema)
>> >
>> > (define my-stream (for/stream ([i (in-range 1 10)])
>> >                     (values "hi" i)))
>> >
>> > When I'm trying to:
>> >
>> > (let-values ([(a b) (stream-ref my-stream 0)])
>> >     (printf "~v: ~v" a b))
>> >
>> > I'm getting:
>> >
>> > ; result arity mismatch;
>> > ;  expected number of values not received
>> > ;   expected: 1
>> > ;   received: 2
>> > ;   values...:
>> > ;    "hi"
>> > ;    2
>> > ; Context:
>> > ;
>> /nix/store/z4mpvw1p6whq454lmjshbdr6472sdbr3-racket-7.6/share/racket/collects/racket/repl.rkt:11:26
>> >
>> > Similarly:
>> >
>> > (for ([(a b) my-stream])
>> >     (printf "~v: ~v" a b))
>> >
>> > leads to:
>> >
>> > ; result arity mismatch;
>> > ;  expected number of values not received
>> > ;   expected: 1
>> > ;   received: 2
>> > ;   values...:
>> > ;    "hi"
>> > ;    1
>> > ; Context:
>> > ;  tcp-accepted:1:1 for-loop
>> > ;  top-level:1:1 [running body]
>> > ;
>> /nix/store/z4mpvw1p6whq454lmjshbdr6472sdbr3-racket-7.6/share/racket/collects/racket/repl.rkt:11:26
>> >
>> > Documentation on stream-ref specifically mentions that it can have
>> > multiple values:
>> >
>> https://docs.racket-lang.org/reference/streams.html?q=stream-ref#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29
>> >
>> > What am I doing wrong here?
>> >
>> > P.S. The context is that I'm trying to create a function that would
>> > return results from an API as a stream that can be iterated with the for
>> > family of forms, and would yield multiple values per iteration.
>> >
>> > --
>> > Yury Bulka
>> > https://mamot.fr/@setthemfree
>> > #NotOnFacebook
>>
>> --
>> 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 racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/87ees2nerz.fsf%40privacyrequired.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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/87d07lo0ax.fsf%40privacyrequired.com.

Reply via email to