samth
2019-12-23 13:57:15

Typically, yes, we’d use threads and channels for that


ryanc
2019-12-23 23:52:02

You should also look at delay/thread, which handles some of the communication for you for simple situations like your example. The difference is that you need to use force to get the value.


ted
2019-12-24 01:09:08

Awesome thanks for your reply, one more question, I’m not sure which way might be more Racket-y ?

(define g5 (delay/thread 5)) (define g6 (delay/thread 6)) (define g7 (delay/thread 7)) (define f5 (force g5)) (define f6 (force g6)) (define f7 (force g7)) (display (+ f5 f6 f7)) Or

(let* ([g5 (delay/thread 5)] [g6 (delay/thread 6)] [g7 (delay/thread 7)] [f5 (force g5)] [f6 (force g6)] [f7 (force g7)]) (display (+ f5 f6 f7)))


notjack
2019-12-24 01:20:55

The define approach is recommended Racket style.



ted
2019-12-24 07:59:36

It’s very useful to know, thanks @notjack