soegaard2
2021-5-2 09:39:54

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


sschwarzer
2021-5-2 21:29:24

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?


notjack
2021-5-2 21:42:17

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


ben.knoble
2021-5-2 21:43:29

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


notjack
2021-5-2 21:44:02

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


ben.knoble
2021-5-2 21:45:48

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…


notjack
2021-5-2 21:51:08

Agreed. That explanation could use a rewrite.


notjack
2021-5-2 21:57:12

I’m gonna update those docs


notjack
2021-5-2 22:13:38

ben.knoble
2021-5-3 00:05:27

That’s already so much better


jake
2021-5-3 06:36:32

@jake has joined the channel



jestarray
2021-5-3 06:45:32

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