On Wed, Feb 20, 2019 at 5:08 PM Jon Zeppieri <zeppi...@gmail.com> 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` here, as well, and make this slightly shorter: (define (reverse-hash h) (for*/hash ([(score letters) (in-hash h)] [letter (in-list letters)]) (values letter score))) `for*/hash` is really a specialized version of `for*/fold`, which handles the hash accumulator for you. The `(values letter score)` expression in the body indicates how the (implicit) accumulator will be updated. -- 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. For more options, visit https://groups.google.com/d/optout.