This repository implements the "off-by-one" programming language described by Randall Munroe, xkcd:
"Any time an integer is stored or read, its value is adjusted upward or downward by a random amount between 40 and 50."
The cartoon is unclear on the following points:
- Is the 40–50 interval open, closed, clopen, …. This implementation chooses [40, 50).
- Whether only integer constants or integer-bound variables are also included. This implementation handles variables as well, for fun.
- Related to the above, whether reading a variable also changes it. I have decided to not allow this. This is because otherwise, even the act of inspecting the variable (e.g., to print it) would change it. That kind of language would, of course, be impossible to program in…
Here is a sample run of client.rkt:
rigi ~/Desktop/r/sk/xkcd-3062> racket client.rkt
u: hello, v: 45, w: -44
u: world, v: -88, w: -44
rigi ~/Desktop/r/sk/xkcd-3062> racket client.rkt
u: hello, v: -42, w: -43
u: world, v: -83, w: -43
rigi ~/Desktop/r/sk/xkcd-3062> racket client.rkt
u: hello, v: -49, w: -48
u: world, v: -6, w: -48
rigi ~/Desktop/r/sk/xkcd-3062> racket client.rkt
u: hello, v: -46, w: 45
u: world, v: 90, w: 45
rigi ~/Desktop/r/sk/xkcd-3062> racket client.rkt
u: hello, v: 42, w: 48
u: world, v: 0, w: 48