Re: [racket-users] for/stream and values

2020-05-03 Thread Yury Bulka
Sorawee Porncharoenwase  writes:

>>
>> 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?
>>
>
> That is correct. Feel free to submit a PR to improve the documentation. You
> will need to edit this file:
> https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/reference/sequences.scrbl#L1186

I have created a draft pull request:
https://github.com/racket/racket/pull/3147

>> 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?
>>
>
> I don't think it's written anywhere explicitly, but you can take a look at
> https://blog.racket-lang.org/2020/02/racket-on-chez-status.html in the
> section "Run-Time Performance Redux", which compares the performance of
> generators in Racket 3m vs Racket CS.

Oh, that's useful. Thank you!

-- 
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/877dxsopth.fsf%40privacyrequired.com.


Re: [racket-users] for/stream and values

2020-05-03 Thread Sorawee Porncharoenwase
>
> 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?
>

That is correct. Feel free to submit a PR to improve the documentation. You
will need to edit this file:
https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/reference/sequences.scrbl#L1186


> 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?
>

I don't think it's written anywhere explicitly, but you can take a look at
https://blog.racket-lang.org/2020/02/racket-on-chez-status.html in the
section "Run-Time Performance Redux", which compares the performance of
generators in Racket 3m vs Racket CS.

-- 
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/CADcuegsWKs4eBLGXWpOggGtrnJBfy6SfCQnT%2BMP3XePmZVdiBg%40mail.gmail.com.


Re: [racket-users] for/stream and values

2020-05-03 Thread Yury Bulka
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  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 
> wrote:
>
>> (sorry for the typos - obviously, it should be racket/stream)
>>
>> --
>> Yury Bulka
>> https://mamot.fr/@setthemfree
>> #NotOnFacebook
>>
>>
>>
>> Yury Bulka  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.


Re: [racket-users] for/stream and values

2020-05-02 Thread Sorawee Porncharoenwase
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 
wrote:

> (sorry for the typos - obviously, it should be racket/stream)
>
> --
> Yury Bulka
> https://mamot.fr/@setthemfree
> #NotOnFacebook
>
>
>
> Yury Bulka  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/CADcuegvfgFo1SPQq6Dh7ncrgCpHDWFBArCSf99WHkOcY5Jjv1A%40mail.gmail.com.


Re: [racket-users] for/stream and values

2020-05-02 Thread Yury Bulka
(sorry for the typos - obviously, it should be racket/stream)

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



Yury Bulka  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.