How does one find the source code for Racket’s quotient/remainder
?
I’ve had poor luck searching through the Github repo
In drracket, type it in the definitions, then right click on it, and Open defining file (iirc)
That won’t work if it’s one of the rare primitives defined in non racket code though. that shouldn’t apply to quotient/remainder though
I think it could me using gmp.
At least in Racker BC. In Racket CS it might be a Chez Scheme primitively.
Ah indeed, there’s not such “Open defining file” for this one, which is a tell that it’s a primitive indeed.
That may be where: https://github.com/racket/racket/blob/master/racket/src/bc/src/numarith.c
that’s for BC though, still looking for CS’ variant
gotcha: https://github.com/racket/racket/blob/master/racket/src/cs/rumble/number.ss#L424 but it does use a primitive too
Wait … that just calls #%$quotient-remainder
. But where is that defined?
My guess is it’s c code
but I can’t find it. Somewhere inside Chez maybe? (isn’t it entirely embedded inside Racket though? I have no idea)
when I have an array arr
what is the best way to check if an index is in bounds? Surely it can’t be as complex as doing array-shape
and running a bunch of if comparisons