
Thanks! For some reason I was looking at an old source file from Cairo.

I don’t really understand the documentation for hash-update!
at https://docs.racket-lang.org/reference/hashtables.html?q=string-join#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._hash-update%21%29%29 .
Specifically, I wonder if this expression can be simplified by using hash-update!
: (hash-set! node-ranks
depth
(cons node-id (hash-ref node-ranks depth '())))
If not, is there a shorter idiom to achieve what I’m doing here?

@sschwarzer yup, that’s equivalent to (hash-update! node-ranks depth (lambda (ids) (cons node-id ids)) '())

I prefer (hash-update! node-ranks depth (curry cons node-id) '())
, but notjack is correct^

if we’re talkin’ lambda sugar: (require fancy-app)
(hash-update! node-ranks depth (cons node-id _) '())

FWIW, the update docs do kind of suck—I think they assume you’re familiar with the idea of a hash-update (SML’s maps support something similar), where instead of the new value for a key you give a function that takes in the old value of the key and transforms it. But they don’t actually say that…

Agreed. That explanation could use a rewrite.

I’m gonna update those docs


That’s already so much better

@jake has joined the channel


racket in the wild! “A RISC-V core in Racket”