Created
February 17, 2025 09:04
-
-
Save Tpaefawzen/922ca8ec0dc7060f4bdbcd965b0656b9 to your computer and use it in GitHub Desktop.
Lua library to implement some arithmetic things for esoteric programming language Dis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return function(base, digits) | |
| local t = { | |
| base = base; | |
| digits = digits; | |
| End = base ^ digits; | |
| Max = base^digits - 1; | |
| }; | |
| function t.is_representable(x) return 0<=x and x<=t.Max end | |
| function t.rot(x) | |
| return x//base + (x%base)*(t.End/base); | |
| end | |
| function t.opr(x, y) | |
| if y <= 0 then return x end | |
| return t.opr(x//base, y//base)*base + (base+x%base-y%base)%base; | |
| end | |
| function t.as_table(x) | |
| local result = {}; | |
| end | |
| return t; | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment