sydney.lambda
2019-9-15 03:26:18

I seem to be writing a lot of patterns like this: (for ([i in-something]) (for ([j in-another-thing] [k in-yet-another-thing]) ...)) in which I’d like both j and k to run “in full” for every iteration of i, but I want j and k to run together, rather than nested. Is this the best way to do it? I’m admittedly not the best with racket’s for/… forms, so I’m probably missing something obvious, but I couldn’t work out how to do this with for*. It can be done with a single for loop using #:when #t between i and the rest of the sequences, but I don’t think that’s preferable. Thank you :)


dan
2019-9-15 03:54:33

@sydney.lambda I haven’t tried this but I think something like this might work: (for* ([i in-something] [(j k) (in-parallel in-another-thing in-yet-another-thing)]) ...) I think in-parallel is what you want: https://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-parallel%29%29


sydney.lambda
2019-9-15 03:59:33

@dan Yup, that seems to do the same job. Thank you :)