> On Feb 21, 2019, at 10:32 PM, Konrad Hinsen
> wrote:
>
> The main difference, as has been pointed out before, is that Python
> generators are more common as an idiom for solving problems that in Racket
> would typically be approached differently.
[[ This is of course ironic in a way,
On 21/02/2019 20:40, Zelphir Kaltstahl wrote:
Python, I believe, has some kind of `Iterable` interface, which a
generator satisfies and which specifies the method to call to get the
next value. In Racket maybe one would have to do with a convention of
how to get a next value from a lazy list.
Yes, that is a key difference to the extent of the laziness I think. The
python generator is different than `for` in racket as what is returned from
calling a generator function in python is not a list at all, its a
generator that must be externally driven in order to produce values.
Whereas
Ah, you are of course right. Somehow I thought about `for/list` and
returning lists and then doing something on the returned list, instead
of simply doing it _inside_ the `for`. Apologies!
On 2/21/19 8:46 PM, Robby Findler wrote:
> For the record, `for` iterators go element-by-element. For
For the record, `for` iterators go element-by-element. For example,
this program does not construct anything that has all of the natural
numbers in it:
#lang racket
(define my-stuffs-value
(hash 'telephone 3
'bluejeans 24
'house 10
'computer 3000))
(define
I don't think one can see `for` in Racket as equivalent to generators in
Python.
Generators in Python are used when you want to save memory by not producing
all values at once, but want to go value by value (which to my knowledge
Racket's `for` variants do not do, but I'd like to be corrected,
Hi Jon,
Thanks for the very detailed explanation. It does make good sense and is
helpful in getting up to speed on racket in general. Regarding the docs,
it does not say "slight", but rather "can provide better", I read this as
slight since it wasn't definitive--but I understand better now
On Wed, Feb 20, 2019 at 9:14 PM Dave McDaniel
wrote:
> Thanks Jon and Jen, This is a great! I figured there must be a
> straightforward way to do this with a `for/hash` implementation. I have
> not seen these 2 methods `in-hash` and `in-list` vs just using the hash or
> list without that
Thanks Jon and Jen, This is a great! I figured there must be a
straightforward way to do this with a `for/hash` implementation. I have
not seen these 2 methods `in-hash` and `in-list` vs just using the hash or
list without that sequence modifier. Can you comment on what is going on
with
On Wed, Feb 20, 2019 at 5:08 PM Jon Zeppieri wrote:
>
> (define (reverse-hash h)
> (for*/fold ([result (hash)])
> ([(score letters) (in-hash h)]
> [letter (in-list letters)])
> (hash-set result letter score)))
>
>
As with Jens's answer, we can use `for*/hash`
Den ons. 20. feb. 2019 kl. 22.25 skrev Dave McDaniel :
> Hello,
>
> I have interest in picking up racket and have done some koans and also
> have been doing the racket track on exercism.
>
> There is a fairly simple exercise called `etl` on exercism related to
> taking a hash for scoring scrabble
On Wed, Feb 20, 2019 at 4:25 PM Dave McDaniel
wrote:
> Hello,
>
> I have interest in picking up racket and have done some koans and also
> have been doing the racket track on exercism.
>
> There is a fairly simple exercise called `etl` on exercism related to
> taking a hash for scoring scrabble
Hello,
I have interest in picking up racket and have done some koans and also have
been doing the racket track on exercism.
There is a fairly simple exercise called `etl` on exercism related to
taking a hash for scoring scrabble letters and unpacking it into a flatter,
more efficient
13 matches
Mail list logo