boeyen
2022-7-13 14:31:05

Is there something like case that works with arbitrary expressions, not datums? I’m trying to do something like…

(define status-not-enqueued 'not-enqueued) (define status-enqueued 'enqueued) (define status-processed 'processed) (define status status-processed) ; imagine this being a much more interesting expression. (case status [(,status-not-enqueued) 1] [(,status-enqueued) 2] [(,status-processsed) 3] [else 4]) But that obviously doesn’t work :slightly_smiling_face: The output is always 4. I don’t want to hardcode the 'not-enqueued (and the other symbols) directly into the case (in case I later decide a different representation for the different kinds of statuses) and I don’t want the repetition of using eq? in a cond. What’s the intended way to do something like this? Or am I stuck with using cond?


boeyen
2022-7-13 14:32:04

Also, I tried joining the Discord but the invite doesn’t seem to work.


boeyen
2022-7-13 14:32:10

laurent.orseau
2022-7-13 14:34:10

People usually use match for this



soegaard2
2022-7-13 14:35:04

Or the good old evcase.


boeyen
2022-7-13 14:42:15

I think I’m going to use evcase because that was exactly what I was looking for… (even if it is from a “legacy library”). Thanks both!


laurent.orseau
2022-7-13 14:42:56

@spdegabrielle :point_up:


laurent.orseau
2022-7-13 14:45:17

otherwise it’s probably just a matter of (define-syntax-rule (eqcase expr [val body ...] ...) (let ([v expr]) (cond [(eq? v val) body ...] ...)))


spdegabrielle
2022-7-13 14:45:49

boeyen
2022-7-13 14:45:50

Nevermind… It’s just Discord giving unclear error messages. I was semi-logged in (as in: I had to enter my password again to open the discord web app, but I was still “logged in” as it was only asking for my password). Been a while since I used Discord.


ben.knoble
2022-7-13 15:11:24

(hash-ref (hash status-not-enqueued 1 status-enqueued 2 status-processed 3) status 4)


laurent.orseau
2022-7-13 15:15:36

(hasheq probably)


spdegabrielle
2022-7-13 15:30:16

Thanks - that’s a relief.


capfredf
2022-7-13 16:15:10

Does the object oriented system support copy constructors?


samth
2022-7-13 17:33:14

No, because there’s no copy operation


bsilverstrim
2022-7-13 17:38:48

Random thought/question (quought?)…has anyone tried making something like a mind map utility using racket, where there are graphics that can be moved around a canvas with click and drag or programmatically lay them out, clicking images can bring up menus or open other windows for navigation, etc.? Any small samples of this type of applications to use for guidance?


ben.knoble
2022-7-13 17:54:54

bsilverstrim
2022-7-13 19:12:12

I’ll take a look, thanks!


spdegabrielle
2022-7-13 20:31:51

I think someone did a long time ago - might be worth a google . Also this might be helpful https://docs.racket-lang.org/draw/Drawing_Conveniences.html#%28part._.Arrows%29\|https://docs.racket-lang.org/draw/Drawing_Conveniences.html#%28part._.Arrows%29

Probably want before curves too


bsilverstrim
2022-7-13 20:38:04

Thank you!


capfredf
2022-7-14 01:54:10

Just to make sure: do we have something to union multiple free-id-tables, i.e. an equivalent to hash-union for hashes?