Last active
December 15, 2021 03:12
-
-
Save minoki/bb1476c07d71360b3d56f5d30f8aaaef to your computer and use it in GitHub Desktop.
Standard ML on LuaTeX: Bernoulli numbers
This file contains 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
local assert = assert | |
local error = error | |
local getmetatable = getmetatable | |
local pairs = pairs | |
local pcall = pcall | |
local setmetatable = setmetatable | |
local math = math | |
local math_abs = math.abs | |
local math_type = math.type | |
local math_maxinteger = math.maxinteger | |
local math_mininteger = math.mininteger | |
local math_ult = math.ult | |
local string = string | |
local string_format = string.format | |
local table = table | |
local table_pack = table.pack | |
local table_unpack = table.unpack | |
local function _Unit_EQUAL(t) | |
return true | |
end | |
local function _Record_EQUAL(fields) | |
return function(t) | |
local a, b = t[1], t[2] | |
for k,eq in pairs(fields) do | |
if not eq({a[k], b[k]}) then | |
return false | |
end | |
end | |
return true | |
end | |
end | |
local function _EQUAL(t) | |
return t[1] == t[2] | |
end | |
local function _id(x) | |
return x | |
end | |
local _exn_meta = {} | |
function _exn_meta:__tostring() | |
local traceback = self.traceback | |
if traceback then | |
traceback = "\n" .. traceback | |
else | |
traceback = "" | |
end | |
return string_format("%s: %s%s", self.location or "<no location info>", self.tag[1], traceback) | |
end | |
local _Match_tag = { "Match" } | |
local _Match = setmetatable({ tag = _Match_tag }, _exn_meta) | |
local _Bind_tag = { "Bind" } | |
local _Bind = setmetatable({ tag = _Bind_tag }, _exn_meta) | |
local _Overflow_tag = { "Overflow" } | |
local _Overflow = setmetatable({ tag = _Overflow_tag }, _exn_meta) | |
local _Div_tag = { "Div" } | |
local _Div = setmetatable({ tag = _Div_tag }, _exn_meta) | |
local _Size_tag = { "Size" } | |
local _Size = setmetatable({ tag = _Size_tag }, _exn_meta) | |
local _Subscript_tag = { "Subscript" } | |
local _Subscript = setmetatable({ tag = _Subscript_tag }, _exn_meta) | |
local _Fail_tag = { "Fail" } | |
local function _Fail(message) | |
return setmetatable({ tag = _Fail_tag, payload = message }, _exn_meta) | |
end | |
local function __exn_instanceof(e, tag) | |
return getmetatable(e) == _exn_meta and e.tag == tag | |
end | |
local function _raise(x, location) | |
local traceback = debug.traceback(nil, 2) | |
local e = setmetatable({ tag = x.tag, payload = x.payload, location = location, traceback = traceback }, _exn_meta) | |
error(e, 1) | |
end | |
-- Int | |
local function __Int_add(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
local z = x + y | |
if y > 0 and z < x then | |
_raise(_Overflow, "Int.+") | |
elseif y < 0 and z > x then | |
_raise(_Overflow, "Int.+") | |
else | |
return z | |
end | |
end | |
local function __Int_sub(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
local z = x - y | |
if y < 0 and z < x then | |
_raise(_Overflow, "Int.-") | |
elseif y > 0 and x < z then | |
_raise(_Overflow, "Int.-") | |
else | |
return z | |
end | |
end | |
local function __Int_mul(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
local z = x * y | |
if (x ~= 0 and z // x ~= y) or (y ~= 0 and z // y ~= x) then | |
_raise(_Overflow, "Int.*") | |
else | |
return z | |
end | |
end | |
local function __Int_div(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
if y == 0 then | |
_raise(_Div, "Int.div") | |
elseif x == math_mininteger and y == -1 then | |
_raise(_Overflow, "Int.div") | |
end | |
return x // y | |
end | |
local function __Int_mod(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
if y == 0 then | |
_raise(_Div, "Int.mod") | |
end | |
return x % y | |
end | |
local function _Int_negate(x) | |
-- assert(math_type(x) == "integer") | |
if x == math_mininteger then | |
_raise(_Overflow, "Int.~") | |
end | |
return - x | |
end | |
local function _Int_abs(x) | |
-- assert(math_type(x) == "integer") | |
if x == math_mininteger then | |
_raise(_Overflow, "Int.abs") | |
end | |
return math_abs(x) | |
end | |
-- Word | |
local function __Word_div(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
if y == 0 then | |
_raise(_Div, "Word.div") | |
elseif y > 0 then | |
if x >= 0 then | |
return x // y | |
else -- x < 0 | |
-- Algorithm from Programming in Lua, 4th ed. | |
local q = ((x >> 1) // y) << 1 | |
local r = x - q * y | |
if math_ult(r, y) then | |
return q | |
else | |
return q + 1 | |
end | |
end | |
else -- y < 0 | |
if math_ult(x, y) then | |
return 0 | |
else | |
return 1 | |
end | |
end | |
end | |
local function __Word_mod(x, y) | |
-- assert(math_type(x) == "integer") | |
-- assert(math_type(y) == "integer") | |
if y == 0 then | |
_raise(_Div, "Word.mod") | |
elseif y > 0 then | |
if x >= 0 then | |
return x % y | |
else -- x < 0 | |
local q = ((x >> 1) // y) << 1 | |
local r = x - q * y | |
if math_ult(r, y) then | |
return r | |
else | |
return r - y | |
end | |
end | |
else -- y < 0 | |
if math_ult(x, y) then | |
return x | |
else | |
return x - y | |
end | |
end | |
end | |
local __Word_LT = math_ult | |
-- List | |
local _nil = { tag = "nil" } | |
local function _cons(t) | |
return { tag = "::", payload = t } | |
end | |
local function _List_EQUAL(eq) | |
local function go(a, b) | |
local at, bt = a.tag, b.tag | |
if at ~= bt then | |
return false | |
elseif at == "nil" then | |
return true | |
elseif eq({a.payload[1], b.payload[1]}) then | |
return go(a.payload[2], b.payload[2]) | |
else | |
return false | |
end | |
end | |
return function(t) | |
return go(t[1], t[2]) | |
end | |
end | |
local function _list(t) | |
local xs = _nil | |
for i = t.n, 1, -1 do | |
xs = { tag = "::", payload = { t[i], xs } } | |
end | |
return xs | |
end | |
-- Ref | |
local function _ref(x) | |
return { tag = "ref", payload = x } | |
end | |
-- Array | |
local function _Array_array(t) | |
local n, init = t[1], t[2] | |
if n < 0 then -- or maxLen < n | |
_raise(_Size, "Array.array") | |
end | |
local t = { n = n } | |
for i = 1, n do | |
t[i] = init | |
end | |
return t | |
end | |
local function _VectorOrArray_fromList(xs) | |
local t = {} | |
local n = 0 | |
while xs.tag == "::" do | |
n = n + 1 | |
t[n] = xs.payload[1] | |
xs = xs.payload[2] | |
end | |
t.n = n | |
return t | |
end | |
local function _VectorOrArray_tabulate(t) | |
local n, f = t[1], t[2] | |
if n < 0 then -- or maxLen < n | |
_raise(_Size, "(Vector|Array).tabulate") | |
end | |
local t = { n = n } | |
for i = 1, n do | |
t[i] = f(i - 1) | |
end | |
return t | |
end | |
-- Vector | |
local function _Vector_EQUAL(eq) | |
local function go(a, b) | |
local n = a.n | |
if n ~= b.n then | |
return false | |
end | |
for i = 1, n do | |
if not eq({a[i], b[i]}) then | |
return false | |
end | |
end | |
return true | |
end | |
return function(t) | |
return go(t[1], t[2]) | |
end | |
end | |
local function _Vector_concat(xs) | |
local n = 0 | |
local t = {} | |
while xs.tag == "::" do | |
local p = xs.payload | |
local u = p[1] | |
local m = u.n | |
for i = 1,m do | |
t[n + i] = u[i] | |
end | |
n = n + m | |
xs = p[2] | |
end | |
t.n = n | |
return t | |
end | |
-- Lua interface | |
local function _Lua_global(name) | |
return _ENV[name] | |
end | |
local function _Lua_call(f) | |
return function(v) | |
return table_pack(f(table_unpack(v, 1, v.n))) | |
end | |
end | |
local function _Lua_method(t) | |
local self, name = t[1], t[2] | |
return function(v) | |
return table_pack(self[name](self, table_unpack(v, 1, v.n))) | |
end | |
end | |
local function _Lua_newTable() | |
return {} | |
end | |
local function _Lua_function(f) | |
return function(...) | |
local r = f(table_pack(...)) | |
return table_unpack(r, 1, r.n) | |
end | |
end | |
local NONE_386 = { tag = "NONE" } | |
local function SOME_385(x) | |
return { tag = "SOME", payload = x } | |
end | |
local sub_547 = function(a_548) | |
local vec_550 = a_548[1] | |
local tmp_9931 = 0 | |
local x_3499 = a_548[2] | |
local tmp0 | |
if x_3499 < tmp_9931 then | |
tmp0 = true | |
else | |
local tmp_9932 | |
do | |
local a_3508 = vec_550 | |
tmp_9932 = a_3508.n | |
end | |
local y_3504 = a_548[2] | |
tmp0 = tmp_9932 <= y_3504 | |
end | |
if tmp0 then | |
_raise(_Subscript, "mlbasis.sml:113:24") | |
else | |
local vec_3517 = a_548[1] | |
local i_3518 = a_548[2] | |
return vec_3517[i_3518 + 1] | |
end | |
end | |
local concat_688, gsub_684, tostring_676 | |
do | |
tostring_676 = _Lua_global("tostring") | |
local tmp_9949 = "gsub" | |
local t_3601 = string | |
local a_3603 | |
do | |
local x_3606 = tmp_9949 | |
local tmp_9951 = x_3606 | |
a_3603 = {t_3601, tmp_9951} | |
end | |
local t_3608 = a_3603[1] | |
local k_3609 = a_3603[2] | |
gsub_684 = t_3608[k_3609] | |
local tmp_9958 = "concat" | |
local t_3634 = table | |
local a_3636 | |
do | |
local x_3639 = tmp_9958 | |
local tmp_9960 = x_3639 | |
a_3636 = {t_3634, tmp_9960} | |
end | |
local t_3641 = a_3636[1] | |
local k_3642 = a_3636[2] | |
concat_688 = t_3641[k_3642] | |
end | |
local EQUAL_892, EQUALorder_1820, GREATER_891, LESS_893 | |
do | |
LESS_893 = { tag = "LESS" } | |
EQUAL_892 = { tag = "EQUAL" } | |
GREATER_891 = { tag = "GREATER" } | |
EQUALorder_1820 = function(p_1821) | |
local tmp1 | |
if p_1821[1].tag == "LESS" then | |
tmp1 = p_1821[2].tag == "LESS" | |
else | |
tmp1 = false | |
end | |
if tmp1 then | |
return true | |
else | |
local tmp2 | |
if p_1821[1].tag == "EQUAL" then | |
tmp2 = p_1821[2].tag == "EQUAL" | |
else | |
tmp2 = false | |
end | |
if tmp2 then | |
return true | |
else | |
local tmp3 | |
if p_1821[1].tag == "GREATER" then | |
tmp3 = p_1821[2].tag == "GREATER" | |
else | |
tmp3 = false | |
end | |
if tmp3 then | |
return true | |
else | |
return false | |
end | |
end | |
end | |
end | |
end | |
do | |
local BIN_922 = { tag = "BIN" } | |
local OCT_921 = { tag = "OCT" } | |
local DEC_920 = { tag = "DEC" } | |
local HEX_919 = { tag = "HEX" } | |
local function SCI_926(x) | |
return { tag = "SCI", payload = x } | |
end | |
local function FIX_925(x) | |
return { tag = "FIX", payload = x } | |
end | |
local function GEN_924(x) | |
return { tag = "GEN", payload = x } | |
end | |
local EXACT_923 = { tag = "EXACT" } | |
end | |
local minInt_946, toString_992 | |
do | |
local a_4243 = math_mininteger | |
local x_4245 = a_4243 | |
minInt_946 = SOME_385(x_4245) | |
toString_992 = function(a_993) | |
local x_4396 = a_993 | |
local result_995 = table_pack(tostring_676(x_4396)) | |
local tmp4 = sub_547({result_995, 0}) | |
local a_4397 = "-" | |
local x_4399 = a_4397 | |
local a_4400 = "~" | |
local x_4402 = a_4400 | |
local result_996 = table_pack(gsub_684(tmp4, x_4399, x_4402)) | |
local a_4406 = sub_547({result_996, 0}) | |
local x_4408 = a_4406 | |
return x_4408 | |
end | |
end | |
local computeWordSize_1008 | |
computeWordSize_1008 = function(a_1009) | |
local x_1011 = a_1009[1] | |
local n_1010 = a_1009[2] | |
if x_1011 == 0 then | |
return n_1010 | |
else | |
local a_4449 | |
do | |
local a_4452 | |
do | |
local a_4456 = x_1011 | |
local x_4458 = a_4456 | |
local tmp_10015 = x_4458 | |
local a_4459 = 1 | |
local x_4461 = a_4459 | |
local tmp_10014 = x_4461 | |
a_4452 = {tmp_10015, tmp_10014} | |
end | |
local x_4454 = a_4452[1] | |
local y_4455 = a_4452[2] | |
a_4449 = x_4454 >> y_4455 | |
end | |
local x_4451 = a_4449 | |
local tmp_10016 = 1 | |
local x_4464 = a_1009[2] | |
local tmp5 = __Int_add(x_4464, tmp_10016) | |
return computeWordSize_1008({x_4451, tmp5}) | |
end | |
end | |
local a_4469 = math_maxinteger | |
local x_4471 = a_4469 | |
local wordSize_1007 = computeWordSize_1008({x_4471, 1}) | |
local copyVec_1600, sub_1591, update_1595 | |
do | |
sub_1591 = function(a_1592) | |
local arr_1594 = a_1592[1] | |
local tmp_10116 = 0 | |
local x_5763 = a_1592[2] | |
local tmp6 | |
if x_5763 < tmp_10116 then | |
tmp6 = true | |
else | |
local tmp_10117 | |
do | |
local a_5772 = arr_1594 | |
tmp_10117 = a_5772.n | |
end | |
local y_5768 = a_1592[2] | |
tmp6 = tmp_10117 <= y_5768 | |
end | |
if tmp6 then | |
_raise(_Subscript, "mlbasis.sml:1217:24") | |
else | |
local arr_5781 = a_1592[1] | |
local i_5782 = a_1592[2] | |
return arr_5781[i_5782 + 1] | |
end | |
end | |
update_1595 = function(a_1596) | |
local arr_1599 = a_1596[1] | |
local tmp_10118 = 0 | |
local x_5785 = a_1596[2] | |
local tmp7 | |
if x_5785 < tmp_10118 then | |
tmp7 = true | |
else | |
local tmp_10119 | |
do | |
local a_5794 = arr_1599 | |
tmp_10119 = a_5794.n | |
end | |
local y_5790 = a_1596[2] | |
tmp7 = tmp_10119 <= y_5790 | |
end | |
if tmp7 then | |
_raise(_Subscript, "mlbasis.sml:1221:34") | |
else | |
local arr_5804 = a_1596[1] | |
local i_5805 = a_1596[2] | |
local v_5806 = a_1596[3] | |
arr_5804[i_5805 + 1] = v_5806 | |
return nil | |
end | |
end | |
copyVec_1600 = function(a_1601) | |
local src_1604 = a_1601["src"] | |
local dst_1603 = a_1601["dst"] | |
local srcLen_1605 | |
do | |
local a_5810 = src_1604 | |
srcLen_1605 = a_5810.n | |
end | |
local tmp_10120 = 0 | |
local y_5816 = a_1601["di"] | |
local tmp8 | |
if tmp_10120 <= y_5816 then | |
local tmp_10122, tmp_10123 | |
do | |
local tmp_10121 | |
do | |
local a_5828 = src_1604 | |
tmp_10121 = a_5828.n | |
end | |
local x_5823 = a_1601["di"] | |
tmp_10123 = __Int_add(x_5823, tmp_10121) | |
local a_5834 = dst_1603 | |
tmp_10122 = a_5834.n | |
end | |
tmp8 = tmp_10123 <= tmp_10122 | |
else | |
tmp8 = false | |
end | |
if tmp8 then | |
local loop_1606 | |
loop_1606 = function(a_1607) | |
if a_1607 >= srcLen_1605 then | |
return nil | |
else | |
local tmp_10124, tmp_10125 | |
do | |
local x_5853 = a_1601["di"] | |
tmp_10125 = __Int_add(x_5853, a_1607) | |
local vec_5861 = a_1601["src"] | |
tmp_10124 = vec_5861[a_1607 + 1] | |
end | |
local arr_5848 = a_1601["dst"] | |
arr_5848[tmp_10125 + 1] = tmp_10124 | |
local tmp_10126 = 1 | |
local tmp9 = __Int_add(a_1607, tmp_10126) | |
return loop_1606(tmp9) | |
end | |
end | |
return loop_1606(0) | |
else | |
_raise(_Subscript, "mlbasis.sml:1235:39") | |
end | |
end | |
end | |
local VectorSlice_1908 | |
do | |
local sub_1855 = function(a_1856) | |
local tmp_10159 = 0 | |
local y_6346 = a_1856[2] | |
local tmp10 | |
if tmp_10159 <= y_6346 then | |
local x_6349 = a_1856[2] | |
local y_6350 = a_1856[1]["length"] | |
tmp10 = x_6349 < y_6350 | |
else | |
tmp10 = false | |
end | |
if tmp10 then | |
local tmp_10160 | |
do | |
local x_6361 = a_1856[1]["start"] | |
local y_6362 = a_1856[2] | |
tmp_10160 = __Int_add(x_6361, y_6362) | |
end | |
local vec_6357 = a_1856[1]["base"] | |
return vec_6357[tmp_10160 + 1] | |
else | |
_raise(_Subscript, "vector-slice.sml:20:44") | |
end | |
end | |
local slice_1864 = function(a_1865) | |
if a_1865[3].tag == "NONE" then | |
local a_1867 = a_1865[1] | |
local i_1866 = a_1865[2] | |
local tmp_10161 = 0 | |
local y_6372 = a_1865[2] | |
local tmp11 | |
if tmp_10161 <= y_6372 then | |
local tmp_10162 | |
do | |
local a_6380 = a_1867 | |
tmp_10162 = a_6380.n | |
end | |
local x_6375 = a_1865[2] | |
tmp11 = x_6375 <= tmp_10162 | |
else | |
tmp11 = false | |
end | |
if tmp11 then | |
local tmp_10163 | |
do | |
local a_6390 = a_1867 | |
tmp_10163 = a_6390.n | |
end | |
local y_6386 = a_1865[2] | |
local tmp12 = __Int_sub(tmp_10163, y_6386) | |
return {["base"] = a_1867, ["start"] = i_1866, ["length"] = tmp12} | |
else | |
_raise(_Subscript, "vector-slice.sml:25:30") | |
end | |
elseif a_1865[3].tag == "SOME" then | |
local a_1870 = a_1865[1] | |
local i_1869 = a_1865[2] | |
local n_1868 = a_1865[3].payload | |
local tmp_10164 = 0 | |
local y_6396 = a_1865[2] | |
local tmp13 | |
if tmp_10164 <= y_6396 then | |
local tmp_10165 = 0 | |
tmp13 = tmp_10165 <= n_1868 | |
else | |
tmp13 = false | |
end | |
local tmp14 | |
if tmp13 then | |
local tmp_10166, tmp_10167 | |
do | |
local x_6407 = a_1865[2] | |
tmp_10167 = __Int_add(x_6407, n_1868) | |
local a_6412 = a_1870 | |
tmp_10166 = a_6412.n | |
end | |
tmp14 = tmp_10167 <= tmp_10166 | |
else | |
tmp14 = false | |
end | |
if tmp14 then | |
return {["base"] = a_1870, ["start"] = i_1869, ["length"] = n_1868} | |
else | |
_raise(_Subscript, "vector-slice.sml:29:32") | |
end | |
else | |
_raise(_Match, "vector-slice.sml:22:5") | |
end | |
end | |
local subslice_1871 = function(a_1872) | |
if a_1872[3].tag == "NONE" then | |
local base_1876 = a_1872[1]["base"] | |
local tmp_10168 = 0 | |
local y_6418 = a_1872[2] | |
local tmp15 | |
if tmp_10168 <= y_6418 then | |
local x_6421 = a_1872[2] | |
local y_6422 = a_1872[1]["length"] | |
tmp15 = x_6421 <= y_6422 | |
else | |
tmp15 = false | |
end | |
if tmp15 then | |
local x_6425 = a_1872[1]["start"] | |
local y_6426 = a_1872[2] | |
local tmp16 = __Int_add(x_6425, y_6426) | |
local x_6429 = a_1872[1]["length"] | |
local y_6430 = a_1872[2] | |
local tmp17 = __Int_sub(x_6429, y_6430) | |
return {["base"] = base_1876, ["start"] = tmp16, ["length"] = tmp17} | |
else | |
_raise(_Subscript, "vector-slice.sml:33:55") | |
end | |
elseif a_1872[3].tag == "SOME" then | |
local base_1881 = a_1872[1]["base"] | |
local n_1877 = a_1872[3].payload | |
local tmp_10169 = 0 | |
local y_6434 = a_1872[2] | |
local tmp18 | |
if tmp_10169 <= y_6434 then | |
local tmp_10170 = 0 | |
tmp18 = tmp_10170 <= n_1877 | |
else | |
tmp18 = false | |
end | |
local tmp19 | |
if tmp18 then | |
local tmp_10171 | |
do | |
local x_6445 = a_1872[2] | |
tmp_10171 = __Int_add(x_6445, n_1877) | |
end | |
local y_6442 = a_1872[1]["length"] | |
tmp19 = tmp_10171 <= y_6442 | |
else | |
tmp19 = false | |
end | |
if tmp19 then | |
local x_6449 = a_1872[1]["start"] | |
local y_6450 = a_1872[2] | |
local tmp20 = __Int_add(x_6449, y_6450) | |
return {["base"] = base_1881, ["start"] = tmp20, ["length"] = n_1877} | |
else | |
_raise(_Subscript, "vector-slice.sml:37:57") | |
end | |
else | |
_raise(_Match, "vector-slice.sml:30:5") | |
end | |
end | |
local exists_1888 = function(a_1889) | |
return function(a_1890) | |
local start_1892 = a_1890["start"] | |
local loop_1895 | |
loop_1895 = function(a_1896) | |
local y_6466 = a_1890["length"] | |
if a_1896 >= y_6466 then | |
return false | |
else | |
local tmp_10173 | |
do | |
local x_6477 = a_1890["start"] | |
tmp_10173 = __Int_add(x_6477, a_1896) | |
end | |
local vec_6473 = a_1890["base"] | |
local tmp21 = a_1889(vec_6473[tmp_10173 + 1]) | |
if tmp21 then | |
return true | |
else | |
local tmp_10174 = 1 | |
local tmp22 = __Int_add(a_1896, tmp_10174) | |
return loop_1895(tmp22) | |
end | |
end | |
end | |
return loop_1895(start_1892) | |
end | |
end | |
local vector_1905 = function(a_6483) | |
local length_6487 = a_6483["length"] | |
return _VectorOrArray_tabulate({length_6487, function(i_6488) | |
local tmp_10175 | |
do | |
local x_6492 = a_6483["start"] | |
tmp_10175 = __Int_add(x_6492, i_6488) | |
end | |
local vec_6495 = a_6483["base"] | |
return vec_6495[tmp_10175 + 1] | |
end}) | |
end | |
local subslice_1904 = subslice_1871 | |
local length_1901 = function(tmp_6497) | |
return tmp_6497["length"] | |
end | |
local full_1900 = function(a_6498) | |
return {["base"] = a_6498, ["start"] = 0, ["length"] = a_6498.n} | |
end | |
VectorSlice_1908 = {["exists"] = exists_1888, ["full"] = full_1900, ["length"] = length_1901, ["slice"] = slice_1864, ["sub"] = sub_1855, ["subslice"] = subslice_1904, ["vector"] = vector_1905} | |
end | |
local ArraySlice_1996 | |
do | |
local sub_1922 = function(a_1923) | |
local tmp_10176 = 0 | |
local y_6507 = a_1923[2] | |
local tmp23 | |
if tmp_10176 <= y_6507 then | |
local x_6510 = a_1923[2] | |
local y_6511 = a_1923[1]["length"] | |
tmp23 = x_6510 < y_6511 | |
else | |
tmp23 = false | |
end | |
if tmp23 then | |
local tmp_10177 | |
do | |
local x_6522 = a_1923[1]["start"] | |
local y_6523 = a_1923[2] | |
tmp_10177 = __Int_add(x_6522, y_6523) | |
end | |
local arr_6518 = a_1923[1]["base"] | |
return arr_6518[tmp_10177 + 1] | |
else | |
_raise(_Subscript, "array-slice.sml:22:44") | |
end | |
end | |
local update_1928 = function(a_1929) | |
local base_1934 = a_1929[1]["base"] | |
local tmp_10178 = 0 | |
local y_6527 = a_1929[2] | |
local tmp24 | |
if tmp_10178 <= y_6527 then | |
local x_6530 = a_1929[2] | |
local y_6531 = a_1929[1]["length"] | |
tmp24 = x_6530 < y_6531 | |
else | |
tmp24 = false | |
end | |
if tmp24 then | |
local a_6537, tmp_10179 | |
do | |
local x_6544 = a_1929[1]["start"] | |
local y_6545 = a_1929[2] | |
tmp_10179 = __Int_add(x_6544, y_6545) | |
a_6537 = {base_1934, tmp_10179} | |
end | |
local arr_6539 = a_1929[1]["base"] | |
local v_6541 = a_6537[3] | |
arr_6539[tmp_10179 + 1] = v_6541 | |
return nil | |
else | |
_raise(_Subscript, "array-slice.sml:26:50") | |
end | |
end | |
local slice_1938 = function(a_1939) | |
if a_1939[3].tag == "NONE" then | |
local a_1941 = a_1939[1] | |
local i_1940 = a_1939[2] | |
local tmp_10180 = 0 | |
local y_6555 = a_1939[2] | |
local tmp25 | |
if tmp_10180 <= y_6555 then | |
local tmp_10181 | |
do | |
local a_6563 = a_1941 | |
tmp_10181 = a_6563.n | |
end | |
local x_6558 = a_1939[2] | |
tmp25 = x_6558 <= tmp_10181 | |
else | |
tmp25 = false | |
end | |
if tmp25 then | |
local tmp_10182 | |
do | |
local a_6573 = a_1941 | |
tmp_10182 = a_6573.n | |
end | |
local y_6569 = a_1939[2] | |
local tmp26 = __Int_sub(tmp_10182, y_6569) | |
return {["base"] = a_1941, ["start"] = i_1940, ["length"] = tmp26} | |
else | |
_raise(_Subscript, "array-slice.sml:31:30") | |
end | |
elseif a_1939[3].tag == "SOME" then | |
local a_1944 = a_1939[1] | |
local i_1943 = a_1939[2] | |
local n_1942 = a_1939[3].payload | |
local tmp_10183 = 0 | |
local y_6579 = a_1939[2] | |
local tmp27 | |
if tmp_10183 <= y_6579 then | |
local tmp_10184 = 0 | |
tmp27 = tmp_10184 <= n_1942 | |
else | |
tmp27 = false | |
end | |
local tmp28 | |
if tmp27 then | |
local tmp_10185, tmp_10186 | |
do | |
local x_6590 = a_1939[2] | |
tmp_10186 = __Int_add(x_6590, n_1942) | |
local a_6595 = a_1944 | |
tmp_10185 = a_6595.n | |
end | |
tmp28 = tmp_10186 <= tmp_10185 | |
else | |
tmp28 = false | |
end | |
if tmp28 then | |
return {["base"] = a_1944, ["start"] = i_1943, ["length"] = n_1942} | |
else | |
_raise(_Subscript, "array-slice.sml:35:32") | |
end | |
else | |
_raise(_Match, "array-slice.sml:28:5") | |
end | |
end | |
local subslice_1945 = function(a_1946) | |
if a_1946[3].tag == "NONE" then | |
local base_1950 = a_1946[1]["base"] | |
local tmp_10187 = 0 | |
local y_6601 = a_1946[2] | |
local tmp29 | |
if tmp_10187 <= y_6601 then | |
local x_6604 = a_1946[2] | |
local y_6605 = a_1946[1]["length"] | |
tmp29 = x_6604 <= y_6605 | |
else | |
tmp29 = false | |
end | |
if tmp29 then | |
local x_6608 = a_1946[1]["start"] | |
local y_6609 = a_1946[2] | |
local tmp30 = __Int_add(x_6608, y_6609) | |
local x_6612 = a_1946[1]["length"] | |
local y_6613 = a_1946[2] | |
local tmp31 = __Int_sub(x_6612, y_6613) | |
return {["base"] = base_1950, ["start"] = tmp30, ["length"] = tmp31} | |
else | |
_raise(_Subscript, "array-slice.sml:39:55") | |
end | |
elseif a_1946[3].tag == "SOME" then | |
local base_1955 = a_1946[1]["base"] | |
local n_1951 = a_1946[3].payload | |
local tmp_10188 = 0 | |
local y_6617 = a_1946[2] | |
local tmp32 | |
if tmp_10188 <= y_6617 then | |
local tmp_10189 = 0 | |
tmp32 = tmp_10189 <= n_1951 | |
else | |
tmp32 = false | |
end | |
local tmp33 | |
if tmp32 then | |
local tmp_10190 | |
do | |
local x_6628 = a_1946[2] | |
tmp_10190 = __Int_add(x_6628, n_1951) | |
end | |
local y_6625 = a_1946[1]["length"] | |
tmp33 = tmp_10190 <= y_6625 | |
else | |
tmp33 = false | |
end | |
if tmp33 then | |
local x_6632 = a_1946[1]["start"] | |
local y_6633 = a_1946[2] | |
local tmp34 = __Int_add(x_6632, y_6633) | |
return {["base"] = base_1955, ["start"] = tmp34, ["length"] = n_1951} | |
else | |
_raise(_Subscript, "array-slice.sml:43:57") | |
end | |
else | |
_raise(_Match, "array-slice.sml:36:5") | |
end | |
end | |
local copy_1962 = function(a_1963) | |
local dst_1965 = a_1963["dst"] | |
local forward_1969 | |
forward_1969 = function(a_1970) | |
local y_6649 = a_1963["src"]["length"] | |
if a_1970 >= y_6649 then | |
return nil | |
else | |
local x_6652 = a_1963["di"] | |
local tmp35 = __Int_add(x_6652, a_1970) | |
local tmp_10192 | |
do | |
local x_6664 = a_1963["src"]["start"] | |
tmp_10192 = __Int_add(x_6664, a_1970) | |
end | |
local arr_6660 = a_1963["src"]["base"] | |
local tmp36 = arr_6660[tmp_10192 + 1] | |
update_1595({dst_1965, tmp35, tmp36}) | |
local tmp_10193 = 1 | |
local tmp37 = __Int_add(a_1970, tmp_10193) | |
return forward_1969(tmp37) | |
end | |
end | |
local backward_1972 | |
backward_1972 = function(a_1973) | |
local tmp_10194 = 0 | |
if a_1973 < tmp_10194 then | |
return nil | |
else | |
local x_6676 = a_1963["di"] | |
local tmp38 = __Int_add(x_6676, a_1973) | |
local tmp_10195 | |
do | |
local x_6688 = a_1963["src"]["start"] | |
tmp_10195 = __Int_add(x_6688, a_1973) | |
end | |
local arr_6684 = a_1963["src"]["base"] | |
local tmp39 = arr_6684[tmp_10195 + 1] | |
update_1595({dst_1965, tmp38, tmp39}) | |
local tmp_10196 = 1 | |
local tmp40 = __Int_sub(a_1973, tmp_10196) | |
return backward_1972(tmp40) | |
end | |
end | |
local x_6696 = a_1963["src"]["start"] | |
local y_6697 = a_1963["di"] | |
if x_6696 >= y_6697 then | |
return forward_1969(0) | |
else | |
local tmp_10197 = 1 | |
local x_6700 = a_1963["src"]["length"] | |
local tmp41 = __Int_sub(x_6700, tmp_10197) | |
return backward_1972(tmp41) | |
end | |
end | |
local copyVec_1975 = function(a_1976) | |
local slice_1979 = a_1976["src"] | |
local dst_1978 = a_1976["dst"] | |
local length_1980 = VectorSlice_1908["length"](slice_1979) | |
local loop_1981 | |
loop_1981 = function(a_1982) | |
if a_1982 >= length_1980 then | |
return nil | |
else | |
local x_6708 = a_1976["di"] | |
local tmp42 = __Int_add(x_6708, a_1982) | |
local tmp43 = VectorSlice_1908["sub"]({slice_1979, a_1982}) | |
update_1595({dst_1978, tmp42, tmp43}) | |
local tmp_10198 = 1 | |
local tmp44 = __Int_add(a_1982, tmp_10198) | |
return loop_1981(tmp44) | |
end | |
end | |
return loop_1981(0) | |
end | |
local vector_1993 = function(a_6714) | |
local length_6718 = a_6714["length"] | |
return _VectorOrArray_tabulate({length_6718, function(i_6719) | |
local tmp_10199 | |
do | |
local x_6723 = a_6714["start"] | |
tmp_10199 = __Int_add(x_6723, i_6719) | |
end | |
local arr_6726 = a_6714["base"] | |
return arr_6726[tmp_10199 + 1] | |
end}) | |
end | |
local update_1992 = update_1928 | |
local subslice_1991 = subslice_1945 | |
local length_1988 = function(tmp_6728) | |
return tmp_6728["length"] | |
end | |
local full_1987 = function(a_6729) | |
return {["base"] = a_6729, ["start"] = 0, ["length"] = a_6729.n} | |
end | |
ArraySlice_1996 = {["copy"] = copy_1962, ["copyVec"] = copyVec_1975, ["full"] = full_1987, ["length"] = length_1988, ["slice"] = slice_1938, ["sub"] = sub_1922, ["subslice"] = subslice_1991, ["update"] = update_1992, ["vector"] = vector_1993} | |
end | |
local tmp45 = (function(a_7686) | |
local x_7688 = a_7686[1] | |
local y_7689 = a_7686[2] | |
local a_7690 = x_7688 == y_7689 | |
return not a_7690 | |
end)({wordSize_1007, 64}) | |
if tmp45 then | |
local tmp46 = _Fail("Word64 is not available") | |
_raise(tmp46, "word64.sml:32:14") | |
end | |
local IntInf_2903, eq_2902 | |
do | |
local ZERO_2339 = { tag = "ZERO" } | |
local function POSITIVE_2338(x) | |
return { tag = "POSITIVE", payload = x } | |
end | |
local function NEGATIVE_2337(x) | |
return { tag = "NEGATIVE", payload = x } | |
end | |
local EQUALint_2895 = function(p_2896) | |
local tmp47 | |
if p_2896[1].tag == "ZERO" then | |
tmp47 = p_2896[2].tag == "ZERO" | |
else | |
tmp47 = false | |
end | |
if tmp47 then | |
return true | |
else | |
local tmp48 | |
if p_2896[1].tag == "POSITIVE" then | |
tmp48 = p_2896[2].tag == "POSITIVE" | |
else | |
tmp48 = false | |
end | |
if tmp48 then | |
local a_2899 = p_2896[1].payload | |
local b_2900 = p_2896[2].payload | |
local tmp49 = _Vector_EQUAL(_EQUAL) | |
return tmp49({a_2899, b_2900}) | |
else | |
local tmp50 | |
if p_2896[1].tag == "NEGATIVE" then | |
tmp50 = p_2896[2].tag == "NEGATIVE" | |
else | |
tmp50 = false | |
end | |
if tmp50 then | |
local a_2897 = p_2896[1].payload | |
local b_2898 = p_2896[2].payload | |
local tmp51 = _Vector_EQUAL(_EQUAL) | |
return tmp51({a_2897, b_2898}) | |
else | |
return false | |
end | |
end | |
end | |
end | |
local toInt_2340 = function(a_2341) | |
if a_2341.tag == "ZERO" then | |
return 0 | |
elseif a_2341.tag == "POSITIVE" then | |
local words_2342 = a_2341.payload | |
local tmp_10368, tmp_10369 | |
do | |
tmp_10369 = words_2342.n | |
tmp_10368 = 1 | |
end | |
if tmp_10369 > tmp_10368 then | |
_raise(_Overflow, "int-inf.sml:66:34") | |
else | |
local x_7716 | |
do | |
local tmp_10370 = 0 | |
x_7716 = words_2342[tmp_10370 + 1] | |
end | |
local a_7717 | |
do | |
local x_7720 = x_7716 | |
local tmp_10372 = x_7720 | |
local a_7721 = 0x0 | |
local x_7723 = a_7721 | |
local tmp_10371 = x_7723 | |
a_7717 = {tmp_10372, tmp_10371} | |
end | |
local x_7725 = a_7717[1] | |
local y_7726 = a_7717[2] | |
local tmp52 = x_7725 < y_7726 | |
if tmp52 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_7727 | |
do | |
local x_7730 = x_7716 | |
a_7727 = x_7730 | |
end | |
local x_7732 = a_7727 | |
return x_7732 | |
end | |
end | |
elseif a_2341.tag == "NEGATIVE" then | |
local words_2343 = a_2341.payload | |
local tmp_10373, tmp_10374 | |
do | |
tmp_10374 = words_2343.n | |
tmp_10373 = 1 | |
end | |
if tmp_10374 > tmp_10373 then | |
_raise(_Overflow, "int-inf.sml:70:34") | |
else | |
local w_2344 | |
do | |
local tmp_10375 = 0 | |
w_2344 = words_2343[tmp_10375 + 1] | |
end | |
local tmp_10388, tmp_10389 | |
do | |
local tmp_10381, tmp_10382 | |
do | |
tmp_10382 = 2 | |
local x_7767 | |
do | |
local tmp_10376 = 0x1 | |
local a_7788 | |
do | |
local a_7789 | |
do | |
local x_7792 = w_2344 | |
local tmp_10378 = x_7792 | |
local x_7795 = tmp_10376 | |
local tmp_10377 = x_7795 | |
a_7789 = {tmp_10378, tmp_10377} | |
end | |
local x_7797 = a_7789[1] | |
local y_7798 = a_7789[2] | |
a_7788 = x_7797 >> y_7798 | |
end | |
local x_7800 = a_7788 | |
x_7767 = x_7800 | |
end | |
local a_7768 | |
do | |
local x_7771 = x_7767 | |
local tmp_10380 = x_7771 | |
local a_7772 = 0x0 | |
local x_7774 = a_7772 | |
local tmp_10379 = x_7774 | |
a_7768 = {tmp_10380, tmp_10379} | |
end | |
local x_7776 = a_7768[1] | |
local y_7777 = a_7768[2] | |
local tmp53 = x_7776 < y_7777 | |
local tmp54 | |
if tmp53 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_7778 | |
do | |
local x_7781 = x_7767 | |
a_7778 = x_7781 | |
end | |
local x_7783 = a_7778 | |
tmp54 = x_7783 | |
end | |
tmp_10381 = _Int_negate(tmp54) | |
end | |
tmp_10389 = __Int_mul(tmp_10382, tmp_10381) | |
local x_7801 | |
do | |
local tmp_10383 = 0x1 | |
local a_7822 | |
do | |
local a_7823 | |
do | |
local x_7826 = w_2344 | |
local tmp_10385 = x_7826 | |
local x_7829 = tmp_10383 | |
local tmp_10384 = x_7829 | |
a_7823 = {tmp_10385, tmp_10384} | |
end | |
local x_7831 = a_7823[1] | |
local y_7832 = a_7823[2] | |
a_7822 = x_7831 & y_7832 | |
end | |
local x_7834 = a_7822 | |
x_7801 = x_7834 | |
end | |
local a_7802 | |
do | |
local x_7805 = x_7801 | |
local tmp_10387 = x_7805 | |
local a_7806 = 0x0 | |
local x_7808 = a_7806 | |
local tmp_10386 = x_7808 | |
a_7802 = {tmp_10387, tmp_10386} | |
end | |
local x_7810 = a_7802[1] | |
local y_7811 = a_7802[2] | |
local tmp55 = x_7810 < y_7811 | |
if tmp55 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_7812 | |
do | |
local x_7815 = x_7801 | |
a_7812 = x_7815 | |
end | |
local x_7817 = a_7812 | |
tmp_10388 = x_7817 | |
end | |
end | |
return __Int_sub(tmp_10389, tmp_10388) | |
end | |
else | |
_raise(_Match, "int-inf.sml:64:5") | |
end | |
end | |
local fromInt_2345 = function(a_2346) | |
if a_2346 == 0 then | |
return ZERO_2339 | |
else | |
local tmp_10390 = 0 | |
if a_2346 > tmp_10390 then | |
local a_7840 | |
do | |
local x_7843 = a_2346 | |
a_7840 = x_7843 | |
end | |
local x_7845 = a_7840 | |
return POSITIVE_2338({ n = 1, x_7845 }) | |
elseif minInt_946.tag == "SOME" then | |
local minInt_2348 = minInt_946.payload | |
local tmp56 = (function(a_7855) | |
local x_7857 = a_7855[1] | |
local y_7858 = a_7855[2] | |
local a_7859 = x_7857 == y_7858 | |
return not a_7859 | |
end)({a_2346, minInt_2348}) | |
if tmp56 then | |
local x_7862 = _Int_abs(a_2346) | |
local a_7863 | |
do | |
local x_7866 = x_7862 | |
a_7863 = x_7866 | |
end | |
local x_7868 = a_7863 | |
return NEGATIVE_2337({ n = 1, x_7868 }) | |
else | |
local a_7869 | |
do | |
local tmp_10391 = 1 | |
local tmp57 = __Int_add(a_2346, tmp_10391) | |
local x_7873 = _Int_abs(tmp57) | |
local a_7874 | |
do | |
local x_7877 = x_7873 | |
a_7874 = x_7877 | |
end | |
local x_7879 = a_7874 | |
local tmp_10393 = x_7879 | |
local tmp_10392 = 0x1 | |
a_7869 = {tmp_10393, tmp_10392} | |
end | |
local x_7871 = a_7869[1] | |
local y_7872 = a_7869[2] | |
return NEGATIVE_2337({ n = 1, x_7871 + y_7872 }) | |
end | |
elseif minInt_946.tag == "NONE" then | |
local x_7884 = _Int_abs(a_2346) | |
local a_7885 | |
do | |
local x_7888 = x_7884 | |
a_7885 = x_7888 | |
end | |
local x_7890 = a_7885 | |
return NEGATIVE_2337({ n = 1, x_7890 }) | |
else | |
_raise(_Match, "int-inf.sml:80:21") | |
end | |
end | |
end | |
local precision_2349 = NONE_386 | |
local minInt_2351 = NONE_386 | |
local maxInt_2353 = NONE_386 | |
local add3_2360 = function(a_2361) | |
local hi1_2365, lo1_2366 | |
do | |
local exp_3330 | |
do | |
local z_7903 | |
do | |
local x_7906 = a_2361[1] | |
local y_7907 = a_2361[2] | |
z_7903 = x_7906 + y_7907 | |
end | |
local y_7911 = a_2361[1] | |
local tmp58 = __Word_LT(z_7903, y_7911) | |
if tmp58 then | |
exp_3330 = {["lo"] = z_7903, ["hi"] = 0x1} | |
else | |
exp_3330 = {["lo"] = z_7903, ["hi"] = 0x0} | |
end | |
end | |
local lo1_2368 = exp_3330["lo"] | |
local hi1_2367 = exp_3330["hi"] | |
hi1_2365, lo1_2366 = table_unpack({hi1_2367, lo1_2368}, 1, 2) | |
end | |
local hi2_2369, lo2_2370 | |
do | |
local exp_3331 | |
do | |
local z_7916 | |
do | |
local y_7920 = a_2361[3] | |
z_7916 = lo1_2366 + y_7920 | |
end | |
local tmp59 = __Word_LT(z_7916, lo1_2366) | |
if tmp59 then | |
exp_3331 = {["lo"] = z_7916, ["hi"] = 0x1} | |
else | |
exp_3331 = {["lo"] = z_7916, ["hi"] = 0x0} | |
end | |
end | |
local lo2_2372 = exp_3331["lo"] | |
local hi2_2371 = exp_3331["hi"] | |
hi2_2369, lo2_2370 = table_unpack({hi2_2371, lo2_2372}, 1, 2) | |
end | |
return {["lo"] = lo2_2370, ["hi"] = hi1_2365 + hi2_2369} | |
end | |
local wordSize__2_2373 | |
do | |
local a_7929 | |
do | |
local a_7934 | |
do | |
local x_7937 = wordSize_1007 | |
a_7934 = x_7937 | |
end | |
local x_7939 = a_7934 | |
local tmp_10395 = x_7939 | |
local tmp_10394 = 0x2 | |
a_7929 = {tmp_10395, tmp_10394} | |
end | |
local x_7931 = a_7929[1] | |
local y_7932 = a_7929[2] | |
wordSize__2_2373 = __Word_div(x_7931, y_7932) | |
end | |
local word__lo__mask_2374 | |
do | |
local a_7940 | |
do | |
local tmp_10396 = 0x1 | |
local a_7948 | |
do | |
local a_7949 | |
do | |
local x_7952 = tmp_10396 | |
local tmp_10398 = x_7952 | |
local x_7955 = wordSize__2_2373 | |
local tmp_10397 = x_7955 | |
a_7949 = {tmp_10398, tmp_10397} | |
end | |
local x_7957 = a_7949[1] | |
local y_7958 = a_7949[2] | |
a_7948 = x_7957 << y_7958 | |
end | |
local x_7960 = a_7948 | |
local tmp_10400 = x_7960 | |
local tmp_10399 = 0x1 | |
a_7940 = {tmp_10400, tmp_10399} | |
end | |
local x_7942 = a_7940[1] | |
local y_7943 = a_7940[2] | |
word__lo__mask_2374 = x_7942 - y_7943 | |
end | |
local mul2_2375 = function(a_2376) | |
if a_2376[1] == 0x0 then | |
return {["lo"] = 0x0, ["hi"] = 0x0} | |
elseif a_2376[2] == 0x0 then | |
return {["lo"] = 0x0, ["hi"] = 0x0} | |
else | |
local x__hi_2379 | |
do | |
local x_7963 = a_2376[1] | |
local a_7965 | |
do | |
local a_7966 | |
do | |
local a_7967 = x_7963 | |
local x_7969 = a_7967 | |
local tmp_10402 = x_7969 | |
local x_7972 = wordSize__2_2373 | |
local tmp_10401 = x_7972 | |
a_7966 = {tmp_10402, tmp_10401} | |
end | |
local x_7974 = a_7966[1] | |
local y_7975 = a_7966[2] | |
a_7965 = x_7974 >> y_7975 | |
end | |
local x_7977 = a_7965 | |
x__hi_2379 = x_7977 | |
end | |
local x__lo_2380 | |
do | |
local x_7980 = a_2376[1] | |
local a_7982 | |
do | |
local a_7983 | |
do | |
local a_7984 = x_7980 | |
local x_7986 = a_7984 | |
local tmp_10404 = x_7986 | |
local x_7989 = word__lo__mask_2374 | |
local tmp_10403 = x_7989 | |
a_7983 = {tmp_10404, tmp_10403} | |
end | |
local x_7991 = a_7983[1] | |
local y_7992 = a_7983[2] | |
a_7982 = x_7991 & y_7992 | |
end | |
local x_7994 = a_7982 | |
x__lo_2380 = x_7994 | |
end | |
local y__hi_2381 | |
do | |
local x_7997 = a_2376[2] | |
local a_7999 | |
do | |
local a_8000 | |
do | |
local a_8001 = x_7997 | |
local x_8003 = a_8001 | |
local tmp_10406 = x_8003 | |
local x_8006 = wordSize__2_2373 | |
local tmp_10405 = x_8006 | |
a_8000 = {tmp_10406, tmp_10405} | |
end | |
local x_8008 = a_8000[1] | |
local y_8009 = a_8000[2] | |
a_7999 = x_8008 >> y_8009 | |
end | |
local x_8011 = a_7999 | |
y__hi_2381 = x_8011 | |
end | |
local y__lo_2382 | |
do | |
local x_8014 = a_2376[2] | |
local a_8016 | |
do | |
local a_8017 | |
do | |
local a_8018 = x_8014 | |
local x_8020 = a_8018 | |
local tmp_10408 = x_8020 | |
local x_8023 = word__lo__mask_2374 | |
local tmp_10407 = x_8023 | |
a_8017 = {tmp_10408, tmp_10407} | |
end | |
local x_8025 = a_8017[1] | |
local y_8026 = a_8017[2] | |
a_8016 = x_8025 & y_8026 | |
end | |
local x_8028 = a_8016 | |
y__lo_2382 = x_8028 | |
end | |
local lo1_2383 = x__lo_2380 * y__lo_2382 | |
local mid1_2384 = x__hi_2379 * y__lo_2382 | |
local lo2_2385 | |
do | |
local a_8041 | |
do | |
local a_8042 | |
do | |
local x_8045 = mid1_2384 | |
local tmp_10410 = x_8045 | |
local x_8048 = wordSize__2_2373 | |
local tmp_10409 = x_8048 | |
a_8042 = {tmp_10410, tmp_10409} | |
end | |
local x_8050 = a_8042[1] | |
local y_8051 = a_8042[2] | |
a_8041 = x_8050 << y_8051 | |
end | |
local x_8053 = a_8041 | |
lo2_2385 = x_8053 | |
end | |
local hi1_2386 | |
do | |
local a_8058 | |
do | |
local a_8059 | |
do | |
local x_8062 = mid1_2384 | |
local tmp_10412 = x_8062 | |
local x_8065 = wordSize__2_2373 | |
local tmp_10411 = x_8065 | |
a_8059 = {tmp_10412, tmp_10411} | |
end | |
local x_8067 = a_8059[1] | |
local y_8068 = a_8059[2] | |
a_8058 = x_8067 >> y_8068 | |
end | |
local x_8070 = a_8058 | |
hi1_2386 = x_8070 | |
end | |
local mid2_2387 = x__lo_2380 * y__hi_2381 | |
local lo3_2388 | |
do | |
local a_8079 | |
do | |
local a_8080 | |
do | |
local x_8083 = mid2_2387 | |
local tmp_10414 = x_8083 | |
local x_8086 = wordSize__2_2373 | |
local tmp_10413 = x_8086 | |
a_8080 = {tmp_10414, tmp_10413} | |
end | |
local x_8088 = a_8080[1] | |
local y_8089 = a_8080[2] | |
a_8079 = x_8088 << y_8089 | |
end | |
local x_8091 = a_8079 | |
lo3_2388 = x_8091 | |
end | |
local hi2_2389 | |
do | |
local a_8096 | |
do | |
local a_8097 | |
do | |
local x_8100 = mid2_2387 | |
local tmp_10416 = x_8100 | |
local x_8103 = wordSize__2_2373 | |
local tmp_10415 = x_8103 | |
a_8097 = {tmp_10416, tmp_10415} | |
end | |
local x_8105 = a_8097[1] | |
local y_8106 = a_8097[2] | |
a_8096 = x_8105 >> y_8106 | |
end | |
local x_8108 = a_8096 | |
hi2_2389 = x_8108 | |
end | |
local hi3_2390 = x__hi_2379 * y__hi_2381 | |
local hi4_2391, lo_2392 | |
do | |
local exp_3333 = add3_2360({lo1_2383, lo2_2385, lo3_2388}) | |
local lo_2394 = exp_3333["lo"] | |
local hi4_2393 = exp_3333["hi"] | |
hi4_2391, lo_2392 = table_unpack({hi4_2393, lo_2394}, 1, 2) | |
end | |
local hi_2395 | |
do | |
local tmp_10418 | |
do | |
local tmp_10417 = hi1_2386 + hi2_2389 | |
tmp_10418 = tmp_10417 + hi3_2390 | |
end | |
hi_2395 = tmp_10418 + hi4_2391 | |
end | |
return {["lo"] = lo_2392, ["hi"] = hi_2395} | |
end | |
end | |
local compareAbs_2396 = function(a_2397) | |
local words_2399 = a_2397[1] | |
local words_PRIME_2398 = a_2397[2] | |
local m_2400 | |
do | |
local a_8128 = words_2399 | |
m_2400 = a_8128.n | |
end | |
local n_2401 | |
do | |
local a_8134 = words_PRIME_2398 | |
n_2401 = a_8134.n | |
end | |
local exp_3335 | |
if m_2400 == n_2401 then | |
exp_3335 = EQUAL_892 | |
elseif m_2400 < n_2401 then | |
exp_3335 = LESS_893 | |
else | |
exp_3335 = GREATER_891 | |
end | |
if exp_3335.tag == "EQUAL" then | |
local loop_2402 | |
loop_2402 = function(a_2403) | |
local tmp_10419 = 0 | |
if a_2403 < tmp_10419 then | |
return EQUAL_892 | |
else | |
local w_2405 | |
do | |
local vec_8155 = a_2397[1] | |
w_2405 = vec_8155[a_2403 + 1] | |
end | |
local w_PRIME_2406 | |
do | |
local vec_8163 = a_2397[2] | |
w_PRIME_2406 = vec_8163[a_2403 + 1] | |
end | |
local exp_3337 | |
if w_2405 == w_PRIME_2406 then | |
exp_3337 = EQUAL_892 | |
else | |
local tmp60 = __Word_LT(w_2405, w_PRIME_2406) | |
if tmp60 then | |
exp_3337 = LESS_893 | |
else | |
exp_3337 = GREATER_891 | |
end | |
end | |
if exp_3337.tag == "EQUAL" then | |
local tmp_10420 = 1 | |
local tmp61 = __Int_sub(a_2403, tmp_10420) | |
return loop_2402(tmp61) | |
else | |
return exp_3337 | |
end | |
end | |
end | |
local tmp_10421 = 1 | |
local tmp62 = __Int_sub(m_2400, tmp_10421) | |
return loop_2402(tmp62) | |
else | |
return exp_3335 | |
end | |
end | |
local normalize_2409 = function(a_2410) | |
local length_2412 | |
do | |
local loop_2413 | |
loop_2413 = function(a_2414) | |
local i_PRIME_2416 | |
do | |
local tmp_10422 = 1 | |
i_PRIME_2416 = __Int_sub(a_2414, tmp_10422) | |
end | |
local tmp_10423 = 0 | |
local tmp63 | |
if i_PRIME_2416 < tmp_10423 then | |
tmp63 = true | |
else | |
local tmp64 = a_2410[i_PRIME_2416 + 1] | |
tmp63 = (function(a_8198) | |
local x_8200 = a_8198[1] | |
local y_8201 = a_8198[2] | |
local a_8202 = x_8200 == y_8201 | |
return not a_8202 | |
end)({tmp64, 0x0}) | |
end | |
if tmp63 then | |
return a_2414 | |
else | |
return loop_2413(i_PRIME_2416) | |
end | |
end | |
length_2412 = loop_2413(a_2410.n) | |
end | |
local tmp65 = SOME_385(length_2412) | |
local tmp66 = ArraySlice_1996["slice"]({a_2410, 0, tmp65}) | |
return ArraySlice_1996["vector"](tmp66) | |
end | |
local addAbs_2417 = function(a_2418) | |
local words_2420 = a_2418[1] | |
local words_PRIME_2419 = a_2418[2] | |
local m_2421 | |
do | |
local a_8222 = words_2420 | |
m_2421 = a_8222.n | |
end | |
local n_2422 | |
do | |
local a_8228 = words_PRIME_2419 | |
n_2422 = a_8228.n | |
end | |
local l_2423 | |
do | |
local tmp_10424, tmp_10425 | |
do | |
if m_2421 < n_2422 then | |
tmp_10425 = n_2422 | |
else | |
tmp_10425 = m_2421 | |
end | |
tmp_10424 = 1 | |
end | |
l_2423 = __Int_add(tmp_10425, tmp_10424) | |
end | |
local arr_2424 = _Array_array({l_2423, 0x0}) | |
local loop_2425 | |
loop_2425 = function(a_2426) | |
local carry_2428 = a_2426[1] | |
local i_2427 = a_2426[2] | |
if i_2427 == l_2423 then | |
return nil | |
else | |
local x_8245 = a_2426[2] | |
local w_2429 | |
if x_8245 < m_2421 then | |
local vec_8253 = a_2418[1] | |
local i_8254 = a_2426[2] | |
w_2429 = vec_8253[i_8254 + 1] | |
else | |
w_2429 = 0x0 | |
end | |
local x_8257 = a_2426[2] | |
local w_PRIME_2430 | |
if x_8257 < n_2422 then | |
local vec_8265 = a_2418[2] | |
local i_8266 = a_2426[2] | |
w_PRIME_2430 = vec_8265[i_8266 + 1] | |
else | |
w_PRIME_2430 = 0x0 | |
end | |
local carry_2431, x_2432 | |
do | |
local exp_3342 = add3_2360({w_2429, w_PRIME_2430, carry_2428}) | |
local x_2434 = exp_3342["lo"] | |
local carry_2433 = exp_3342["hi"] | |
carry_2431, x_2432 = table_unpack({carry_2433, x_2434}, 1, 2) | |
end | |
local i_8275 = a_2426[2] | |
arr_2424[i_8275 + 1] = x_2432 | |
local tmp_10426 = 1 | |
local x_8279 = a_2426[2] | |
local tmp67 = __Int_add(x_8279, tmp_10426) | |
return loop_2425({carry_2431, tmp67}) | |
end | |
end | |
loop_2425({0x0, 0}) | |
return normalize_2409(arr_2424) | |
end | |
local subAbs_2435 = function(a_2436) | |
local words_2438 = a_2436[1] | |
local words_PRIME_2437 = a_2436[2] | |
local m_2439 | |
do | |
local a_8284 = words_2438 | |
m_2439 = a_8284.n | |
end | |
local n_2440 | |
do | |
local a_8290 = words_PRIME_2437 | |
n_2440 = a_8290.n | |
end | |
local arr_2441 = _Array_array({m_2439, 0x0}) | |
local loop_2442 | |
loop_2442 = function(a_2443) | |
local carry_2445 = a_2443[1] | |
local i_2444 = a_2443[2] | |
if i_2444 == m_2439 then | |
if carry_2445 == 0x0 then | |
return nil | |
else | |
local tmp68 = _Fail("subAbs: carry not zero") | |
_raise(tmp68, "int-inf.sml:188:77") | |
end | |
else | |
local w_2446 | |
do | |
local vec_8299 = a_2436[1] | |
local i_8300 = a_2443[2] | |
w_2446 = vec_8299[i_8300 + 1] | |
end | |
local x_8303 = a_2443[2] | |
local w_PRIME_2447 | |
if x_8303 < n_2440 then | |
local vec_8311 = a_2436[2] | |
local i_8312 = a_2443[2] | |
w_PRIME_2447 = vec_8311[i_8312 + 1] | |
else | |
w_PRIME_2447 = 0x0 | |
end | |
local carry_2448, lo_2449 | |
do | |
local tmp69 = __Word_LT(w_2446, w_PRIME_2447) | |
local exp_3345 | |
if tmp69 then | |
local tmp_10427 = w_2446 - w_PRIME_2447 | |
local y_8320 = a_2443[1] | |
exp_3345 = {["lo"] = tmp_10427 - y_8320, ["hi"] = 0x1} | |
else | |
local tmp70 = __Word_LT(w_PRIME_2447, w_2446) | |
if tmp70 then | |
local tmp_10428 = w_2446 - w_PRIME_2447 | |
local y_8336 = a_2443[1] | |
exp_3345 = {["lo"] = tmp_10428 - y_8336, ["hi"] = 0x0} | |
elseif carry_2445 == 0x0 then | |
exp_3345 = {["lo"] = 0x0, ["hi"] = 0x0} | |
else | |
local a_8341 = carry_2445 | |
exp_3345 = {["lo"] = - a_8341, ["hi"] = 0x1} | |
end | |
end | |
local lo_2451 = exp_3345["lo"] | |
local carry_2450 = exp_3345["hi"] | |
carry_2448, lo_2449 = table_unpack({carry_2450, lo_2451}, 1, 2) | |
end | |
local i_8352 = a_2443[2] | |
arr_2441[i_8352 + 1] = lo_2449 | |
local tmp_10429 = 1 | |
local x_8356 = a_2443[2] | |
local tmp71 = __Int_add(x_8356, tmp_10429) | |
return loop_2442({carry_2448, tmp71}) | |
end | |
end | |
loop_2442({0x0, 0}) | |
return normalize_2409(arr_2441) | |
end | |
local mulAbs_2452 = function(a_2453) | |
local words_2455 = a_2453[1] | |
local words_PRIME_2454 = a_2453[2] | |
local m_2456 | |
do | |
local a_8361 = words_2455 | |
m_2456 = a_8361.n | |
end | |
local n_2457 | |
do | |
local a_8367 = words_PRIME_2454 | |
n_2457 = a_8367.n | |
end | |
local m__n_2458 = __Int_add(m_2456, n_2457) | |
local arr_2459 = _Array_array({m__n_2458, 0x0}) | |
local outer_2460 | |
outer_2460 = function(a_2461) | |
if a_2461 >= n_2457 then | |
return nil | |
else | |
local v_2463 | |
do | |
local vec_8384 = a_2453[2] | |
v_2463 = vec_8384[a_2461 + 1] | |
end | |
local inner_2464 | |
inner_2464 = function(a_2465) | |
local k_2466 = a_2465[2] | |
local x_8388 = a_2465[1] | |
if x_8388 >= m_2456 then | |
local tmp_10430 | |
do | |
local x_8402 = a_2465[1] | |
tmp_10430 = __Int_add(x_8402, a_2461) | |
end | |
local v_8399 = a_2465[2] | |
arr_2459[tmp_10430 + 1] = v_8399 | |
return nil | |
else | |
local u_2468 | |
do | |
local vec_8410 = a_2453[1] | |
local i_8411 = a_2465[1] | |
u_2468 = vec_8410[i_8411 + 1] | |
end | |
local hi_2469, lo_2470 | |
do | |
local exp_3349 = mul2_2375({u_2468, v_2463}) | |
local lo_2472 = exp_3349["lo"] | |
local hi_2471 = exp_3349["hi"] | |
hi_2469, lo_2470 = table_unpack({hi_2471, lo_2472}, 1, 2) | |
end | |
local hi_PRIME_2473, lo_2474 | |
do | |
local tmp_10431 | |
do | |
local x_8422 = a_2465[1] | |
tmp_10431 = __Int_add(x_8422, a_2461) | |
end | |
local tmp72 = arr_2459[tmp_10431 + 1] | |
local exp_3350 = add3_2360({lo_2470, tmp72, k_2466}) | |
local lo_2476 = exp_3350["lo"] | |
local hi_PRIME_2475 = exp_3350["hi"] | |
hi_PRIME_2473, lo_2474 = table_unpack({hi_PRIME_2475, lo_2476}, 1, 2) | |
end | |
local tmp_10432 | |
do | |
local x_8436 = a_2465[1] | |
tmp_10432 = __Int_add(x_8436, a_2461) | |
end | |
arr_2459[tmp_10432 + 1] = lo_2474 | |
local tmp_10433 = 1 | |
local x_8440 = a_2465[1] | |
local tmp73 = __Int_add(x_8440, tmp_10433) | |
return inner_2464({tmp73, hi_2469 + hi_PRIME_2473}) | |
end | |
end | |
inner_2464({0, 0x0}) | |
local tmp_10434 = 1 | |
local tmp74 = __Int_add(a_2461, tmp_10434) | |
return outer_2460(tmp74) | |
end | |
end | |
outer_2460(0) | |
return normalize_2409(arr_2459) | |
end | |
local mulAbsSingle_2477 = function(a_2478) | |
if a_2478[2] == 0x0 then | |
return { n = 0 } | |
else | |
local words_2481 = a_2478[1] | |
local v_2480 = a_2478[2] | |
local m_2482 | |
do | |
local a_8453 = words_2481 | |
m_2482 = a_8453.n | |
end | |
local tmp_10435 = 1 | |
local tmp75 = __Int_add(m_2482, tmp_10435) | |
local arr_2483 = _Array_array({tmp75, 0x0}) | |
local loop_2484 | |
loop_2484 = function(a_2485) | |
local x_8462 = a_2485[1] | |
if x_8462 >= m_2482 then | |
local i_8472 = a_2485[1] | |
local v_8473 = a_2485[2] | |
arr_2483[i_8472 + 1] = v_8473 | |
return nil | |
else | |
local u_2488 | |
do | |
local vec_8480 = a_2478[1] | |
local i_8481 = a_2485[1] | |
u_2488 = vec_8480[i_8481 + 1] | |
end | |
local hi_2489, lo_2490 | |
do | |
local exp_3353 = mul2_2375({u_2488, v_2480}) | |
local lo_2492 = exp_3353["lo"] | |
local hi_2491 = exp_3353["hi"] | |
hi_2489, lo_2490 = table_unpack({hi_2491, lo_2492}, 1, 2) | |
end | |
local hi_PRIME_2493, lo_2494 | |
do | |
local exp_3354 | |
do | |
local z_8486 | |
do | |
local y_8490 = a_2485[2] | |
z_8486 = lo_2490 + y_8490 | |
end | |
local tmp76 = __Word_LT(z_8486, lo_2490) | |
if tmp76 then | |
exp_3354 = {["lo"] = z_8486, ["hi"] = 0x1} | |
else | |
exp_3354 = {["lo"] = z_8486, ["hi"] = 0x0} | |
end | |
end | |
local lo_2496 = exp_3354["lo"] | |
local hi_PRIME_2495 = exp_3354["hi"] | |
hi_PRIME_2493, lo_2494 = table_unpack({hi_PRIME_2495, lo_2496}, 1, 2) | |
end | |
local i_8503 = a_2485[1] | |
arr_2483[i_8503 + 1] = lo_2494 | |
local tmp_10436 = 1 | |
local x_8507 = a_2485[1] | |
local tmp77 = __Int_add(x_8507, tmp_10436) | |
return loop_2484({tmp77, hi_2489 + hi_PRIME_2493}) | |
end | |
end | |
loop_2484({0, 0x0}) | |
return normalize_2409(arr_2483) | |
end | |
end | |
local negate_2497 = function(a_2498) | |
if a_2498.tag == "POSITIVE" then | |
local words_2499 = a_2498.payload | |
return NEGATIVE_2337(words_2499) | |
elseif a_2498.tag == "NEGATIVE" then | |
local words_2500 = a_2498.payload | |
return POSITIVE_2338(words_2500) | |
else | |
return a_2498 | |
end | |
end | |
local add_2502 = function(a_2503) | |
if a_2503[1].tag == "ZERO" then | |
local y_2504 = a_2503[2] | |
return y_2504 | |
elseif a_2503[2].tag == "ZERO" then | |
local x_2505 = a_2503[1] | |
return x_2505 | |
else | |
local tmp78 | |
if a_2503[1].tag == "POSITIVE" then | |
tmp78 = a_2503[2].tag == "POSITIVE" | |
else | |
tmp78 = false | |
end | |
if tmp78 then | |
local words_2507 = a_2503[1].payload | |
local words_PRIME_2506 = a_2503[2].payload | |
local tmp79 = addAbs_2417({words_2507, words_PRIME_2506}) | |
return POSITIVE_2338(tmp79) | |
else | |
local tmp80 | |
if a_2503[1].tag == "POSITIVE" then | |
tmp80 = a_2503[2].tag == "NEGATIVE" | |
else | |
tmp80 = false | |
end | |
if tmp80 then | |
local words_2509 = a_2503[1].payload | |
local words_PRIME_2508 = a_2503[2].payload | |
local exp_3357 = compareAbs_2396({words_2509, words_PRIME_2508}) | |
if exp_3357.tag == "LESS" then | |
local tmp81 = subAbs_2435({words_PRIME_2508, words_2509}) | |
return NEGATIVE_2337(tmp81) | |
elseif exp_3357.tag == "GREATER" then | |
local tmp82 = subAbs_2435({words_2509, words_PRIME_2508}) | |
return POSITIVE_2338(tmp82) | |
elseif exp_3357.tag == "EQUAL" then | |
return ZERO_2339 | |
else | |
_raise(_Match, "int-inf.sml:259:46") | |
end | |
else | |
local tmp83 | |
if a_2503[1].tag == "NEGATIVE" then | |
tmp83 = a_2503[2].tag == "POSITIVE" | |
else | |
tmp83 = false | |
end | |
if tmp83 then | |
local words_2511 = a_2503[1].payload | |
local words_PRIME_2510 = a_2503[2].payload | |
local exp_3358 = compareAbs_2396({words_2511, words_PRIME_2510}) | |
if exp_3358.tag == "LESS" then | |
local tmp84 = subAbs_2435({words_PRIME_2510, words_2511}) | |
return POSITIVE_2338(tmp84) | |
elseif exp_3358.tag == "GREATER" then | |
local tmp85 = subAbs_2435({words_2511, words_PRIME_2510}) | |
return NEGATIVE_2337(tmp85) | |
elseif exp_3358.tag == "EQUAL" then | |
return ZERO_2339 | |
else | |
_raise(_Match, "int-inf.sml:264:46") | |
end | |
else | |
local tmp86 | |
if a_2503[1].tag == "NEGATIVE" then | |
tmp86 = a_2503[2].tag == "NEGATIVE" | |
else | |
tmp86 = false | |
end | |
if tmp86 then | |
local words_2513 = a_2503[1].payload | |
local words_PRIME_2512 = a_2503[2].payload | |
local tmp87 = addAbs_2417({words_2513, words_PRIME_2512}) | |
return NEGATIVE_2337(tmp87) | |
else | |
_raise(_Match, "int-inf.sml:256:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local sub_2514 = function(a_2515) | |
if a_2515[2].tag == "ZERO" then | |
local x_2516 = a_2515[1] | |
return x_2516 | |
else | |
local tmp88 | |
if a_2515[1].tag == "ZERO" then | |
tmp88 = a_2515[2].tag == "POSITIVE" | |
else | |
tmp88 = false | |
end | |
if tmp88 then | |
local words_2517 = a_2515[2].payload | |
return NEGATIVE_2337(words_2517) | |
else | |
local tmp89 | |
if a_2515[1].tag == "ZERO" then | |
tmp89 = a_2515[2].tag == "NEGATIVE" | |
else | |
tmp89 = false | |
end | |
if tmp89 then | |
local words_2518 = a_2515[2].payload | |
return POSITIVE_2338(words_2518) | |
else | |
local tmp90 | |
if a_2515[1].tag == "POSITIVE" then | |
tmp90 = a_2515[2].tag == "POSITIVE" | |
else | |
tmp90 = false | |
end | |
if tmp90 then | |
local words_2520 = a_2515[1].payload | |
local words_PRIME_2519 = a_2515[2].payload | |
local exp_3360 = compareAbs_2396({words_2520, words_PRIME_2519}) | |
if exp_3360.tag == "LESS" then | |
local tmp91 = subAbs_2435({words_PRIME_2519, words_2520}) | |
return NEGATIVE_2337(tmp91) | |
elseif exp_3360.tag == "GREATER" then | |
local tmp92 = subAbs_2435({words_2520, words_PRIME_2519}) | |
return POSITIVE_2338(tmp92) | |
elseif exp_3360.tag == "EQUAL" then | |
return ZERO_2339 | |
else | |
_raise(_Match, "int-inf.sml:274:46") | |
end | |
else | |
local tmp93 | |
if a_2515[1].tag == "POSITIVE" then | |
tmp93 = a_2515[2].tag == "NEGATIVE" | |
else | |
tmp93 = false | |
end | |
if tmp93 then | |
local words_2522 = a_2515[1].payload | |
local words_PRIME_2521 = a_2515[2].payload | |
local tmp94 = addAbs_2417({words_2522, words_PRIME_2521}) | |
return POSITIVE_2338(tmp94) | |
else | |
local tmp95 | |
if a_2515[1].tag == "NEGATIVE" then | |
tmp95 = a_2515[2].tag == "POSITIVE" | |
else | |
tmp95 = false | |
end | |
if tmp95 then | |
local words_2524 = a_2515[1].payload | |
local words_PRIME_2523 = a_2515[2].payload | |
local tmp96 = addAbs_2417({words_2524, words_PRIME_2523}) | |
return NEGATIVE_2337(tmp96) | |
else | |
local tmp97 | |
if a_2515[1].tag == "NEGATIVE" then | |
tmp97 = a_2515[2].tag == "NEGATIVE" | |
else | |
tmp97 = false | |
end | |
if tmp97 then | |
local words_2526 = a_2515[1].payload | |
local words_PRIME_2525 = a_2515[2].payload | |
local exp_3361 = compareAbs_2396({words_2526, words_PRIME_2525}) | |
if exp_3361.tag == "LESS" then | |
local tmp98 = subAbs_2435({words_PRIME_2525, words_2526}) | |
return POSITIVE_2338(tmp98) | |
elseif exp_3361.tag == "GREATER" then | |
local tmp99 = subAbs_2435({words_2526, words_PRIME_2525}) | |
return NEGATIVE_2337(tmp99) | |
elseif exp_3361.tag == "EQUAL" then | |
return ZERO_2339 | |
else | |
_raise(_Match, "int-inf.sml:281:46") | |
end | |
else | |
_raise(_Match, "int-inf.sml:271:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
local mul_2527 = function(a_2528) | |
if a_2528[1].tag == "ZERO" then | |
local z_2529 = a_2528[1] | |
return z_2529 | |
elseif a_2528[2].tag == "ZERO" then | |
local z_2530 = a_2528[2] | |
return z_2530 | |
else | |
local tmp100 | |
if a_2528[1].tag == "POSITIVE" then | |
tmp100 = a_2528[2].tag == "POSITIVE" | |
else | |
tmp100 = false | |
end | |
if tmp100 then | |
local words_2532 = a_2528[1].payload | |
local words_PRIME_2531 = a_2528[2].payload | |
local tmp101 = mulAbs_2452({words_2532, words_PRIME_2531}) | |
return POSITIVE_2338(tmp101) | |
else | |
local tmp102 | |
if a_2528[1].tag == "POSITIVE" then | |
tmp102 = a_2528[2].tag == "NEGATIVE" | |
else | |
tmp102 = false | |
end | |
if tmp102 then | |
local words_2534 = a_2528[1].payload | |
local words_PRIME_2533 = a_2528[2].payload | |
local tmp103 = mulAbs_2452({words_2534, words_PRIME_2533}) | |
return NEGATIVE_2337(tmp103) | |
else | |
local tmp104 | |
if a_2528[1].tag == "NEGATIVE" then | |
tmp104 = a_2528[2].tag == "POSITIVE" | |
else | |
tmp104 = false | |
end | |
if tmp104 then | |
local words_2536 = a_2528[1].payload | |
local words_PRIME_2535 = a_2528[2].payload | |
local tmp105 = mulAbs_2452({words_2536, words_PRIME_2535}) | |
return NEGATIVE_2337(tmp105) | |
else | |
local tmp106 | |
if a_2528[1].tag == "NEGATIVE" then | |
tmp106 = a_2528[2].tag == "NEGATIVE" | |
else | |
tmp106 = false | |
end | |
if tmp106 then | |
local words_2538 = a_2528[1].payload | |
local words_PRIME_2537 = a_2528[2].payload | |
local tmp107 = mulAbs_2452({words_2538, words_PRIME_2537}) | |
return POSITIVE_2338(tmp107) | |
else | |
_raise(_Match, "int-inf.sml:287:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local LT_2539 = function(a_2540) | |
local tmp108 | |
if a_2540[1].tag == "ZERO" then | |
tmp108 = a_2540[2].tag == "ZERO" | |
else | |
tmp108 = false | |
end | |
if tmp108 then | |
return false | |
else | |
local tmp109 | |
if a_2540[1].tag == "ZERO" then | |
tmp109 = a_2540[2].tag == "POSITIVE" | |
else | |
tmp109 = false | |
end | |
if tmp109 then | |
return true | |
else | |
local tmp110 | |
if a_2540[1].tag == "ZERO" then | |
tmp110 = a_2540[2].tag == "NEGATIVE" | |
else | |
tmp110 = false | |
end | |
if tmp110 then | |
return false | |
else | |
local tmp111 | |
if a_2540[1].tag == "POSITIVE" then | |
tmp111 = a_2540[2].tag == "POSITIVE" | |
else | |
tmp111 = false | |
end | |
if tmp111 then | |
local words_2542 = a_2540[1].payload | |
local words_PRIME_2541 = a_2540[2].payload | |
local tmp112 = compareAbs_2396({words_2542, words_PRIME_2541}) | |
return EQUALorder_1820({tmp112, LESS_893}) | |
elseif a_2540[1].tag == "POSITIVE" then | |
return false | |
else | |
local tmp113 | |
if a_2540[1].tag == "NEGATIVE" then | |
tmp113 = a_2540[2].tag == "NEGATIVE" | |
else | |
tmp113 = false | |
end | |
if tmp113 then | |
local words_2544 = a_2540[1].payload | |
local words_PRIME_2543 = a_2540[2].payload | |
local tmp114 = compareAbs_2396({words_2544, words_PRIME_2543}) | |
return EQUALorder_1820({tmp114, GREATER_891}) | |
elseif a_2540[1].tag == "NEGATIVE" then | |
return true | |
else | |
_raise(_Match, "int-inf.sml:294:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local compare_2545 = function(a_2546) | |
local tmp115 | |
if a_2546[1].tag == "ZERO" then | |
tmp115 = a_2546[2].tag == "ZERO" | |
else | |
tmp115 = false | |
end | |
if tmp115 then | |
return EQUAL_892 | |
else | |
local tmp116 | |
if a_2546[1].tag == "ZERO" then | |
tmp116 = a_2546[2].tag == "POSITIVE" | |
else | |
tmp116 = false | |
end | |
if tmp116 then | |
return LESS_893 | |
else | |
local tmp117 | |
if a_2546[1].tag == "ZERO" then | |
tmp117 = a_2546[2].tag == "NEGATIVE" | |
else | |
tmp117 = false | |
end | |
if tmp117 then | |
return GREATER_891 | |
else | |
local tmp118 | |
if a_2546[1].tag == "POSITIVE" then | |
tmp118 = a_2546[2].tag == "POSITIVE" | |
else | |
tmp118 = false | |
end | |
if tmp118 then | |
local words_2548 = a_2546[1].payload | |
local words_PRIME_2547 = a_2546[2].payload | |
return compareAbs_2396({words_2548, words_PRIME_2547}) | |
elseif a_2546[1].tag == "POSITIVE" then | |
return GREATER_891 | |
else | |
local tmp119 | |
if a_2546[1].tag == "NEGATIVE" then | |
tmp119 = a_2546[2].tag == "NEGATIVE" | |
else | |
tmp119 = false | |
end | |
if tmp119 then | |
local words_2550 = a_2546[1].payload | |
local words_PRIME_2549 = a_2546[2].payload | |
return compareAbs_2396({words_PRIME_2549, words_2550}) | |
elseif a_2546[1].tag == "NEGATIVE" then | |
return LESS_893 | |
else | |
_raise(_Match, "int-inf.sml:302:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local LShiftAbs_2551 = function(a_2552) | |
local words_2554 = a_2552[1] | |
local amount_2553 = a_2552[2] | |
local major_2555 | |
do | |
local a_8513 | |
do | |
local a_8518 | |
do | |
local x_8521 = wordSize_1007 | |
a_8518 = x_8521 | |
end | |
local x_8523 = a_8518 | |
local tmp_10437 = x_8523 | |
a_8513 = {amount_2553, tmp_10437} | |
end | |
local x_8515 = a_8513[1] | |
local y_8516 = a_8513[2] | |
major_2555 = __Word_div(x_8515, y_8516) | |
end | |
local minor_2556 | |
do | |
local a_8524 | |
do | |
local a_8529 | |
do | |
local x_8532 = wordSize_1007 | |
a_8529 = x_8532 | |
end | |
local x_8534 = a_8529 | |
local tmp_10438 = x_8534 | |
a_8524 = {amount_2553, tmp_10438} | |
end | |
local x_8526 = a_8524[1] | |
local y_8527 = a_8524[2] | |
minor_2556 = __Word_mod(x_8526, y_8527) | |
end | |
local n_2557 | |
do | |
local tmp_10441, tmp_10442 | |
do | |
local a_8542 = words_2554 | |
tmp_10442 = a_8542.n | |
local a_8546 | |
do | |
local x_8549 = major_2555 | |
local tmp_10440 = x_8549 | |
local a_8550 = 0x0 | |
local x_8552 = a_8550 | |
local tmp_10439 = x_8552 | |
a_8546 = {tmp_10440, tmp_10439} | |
end | |
local x_8554 = a_8546[1] | |
local y_8555 = a_8546[2] | |
local tmp120 = x_8554 < y_8555 | |
if tmp120 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8556 | |
do | |
local x_8559 = major_2555 | |
a_8556 = x_8559 | |
end | |
local x_8561 = a_8556 | |
tmp_10441 = x_8561 | |
end | |
end | |
n_2557 = __Int_add(tmp_10442, tmp_10441) | |
end | |
if minor_2556 == 0x0 then | |
return _VectorOrArray_tabulate({n_2557, function(i_2558) | |
local a_8567 | |
do | |
local x_8570 = major_2555 | |
local tmp_10444 = x_8570 | |
local a_8571 = 0x0 | |
local x_8573 = a_8571 | |
local tmp_10443 = x_8573 | |
a_8567 = {tmp_10444, tmp_10443} | |
end | |
local x_8575 = a_8567[1] | |
local y_8576 = a_8567[2] | |
local tmp121 = x_8575 < y_8576 | |
local tmp_10445 | |
if tmp121 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8577 | |
do | |
local x_8580 = major_2555 | |
a_8577 = x_8580 | |
end | |
local x_8582 = a_8577 | |
tmp_10445 = x_8582 | |
end | |
if i_2558 < tmp_10445 then | |
return 0x0 | |
else | |
local tmp_10449 | |
do | |
local a_8596 | |
do | |
local x_8599 = major_2555 | |
local tmp_10447 = x_8599 | |
local a_8600 = 0x0 | |
local x_8602 = a_8600 | |
local tmp_10446 = x_8602 | |
a_8596 = {tmp_10447, tmp_10446} | |
end | |
local x_8604 = a_8596[1] | |
local y_8605 = a_8596[2] | |
local tmp122 = x_8604 < y_8605 | |
local tmp_10448 | |
if tmp122 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8606 | |
do | |
local x_8609 = major_2555 | |
a_8606 = x_8609 | |
end | |
local x_8611 = a_8606 | |
tmp_10448 = x_8611 | |
end | |
tmp_10449 = __Int_sub(i_2558, tmp_10448) | |
end | |
local vec_8589 = a_2552[1] | |
return vec_8589[tmp_10449 + 1] | |
end | |
end}) | |
else | |
local m_2559 | |
do | |
local tmp_10450 = 1 | |
m_2559 = __Int_add(n_2557, tmp_10450) | |
end | |
local arr_2560 = _Array_array({m_2559, 0x0}) | |
local loop_2561 | |
loop_2561 = function(a_2562) | |
local lo_2564 = a_2562[1] | |
local i_2563 = a_2562[2] | |
if i_2563 == m_2559 then | |
if lo_2564 == 0x0 then | |
return nil | |
else | |
local tmp123 = _Fail("LShiftAbs: carry not zero") | |
_raise(tmp123, "int-inf.sml:326:84") | |
end | |
else | |
local x_8618 = a_2562[2] | |
local w_2565 | |
if x_8618 < n_2557 then | |
local vec_8626 = a_2552[1] | |
local i_8627 = a_2562[2] | |
w_2565 = vec_8626[i_8627 + 1] | |
else | |
w_2565 = 0x0 | |
end | |
local v_2566 | |
do | |
local a_8628 | |
do | |
local a_8649 | |
do | |
local a_8650 | |
do | |
local x_8653 = w_2565 | |
local tmp_10452 = x_8653 | |
local x_8656 = minor_2556 | |
local tmp_10451 = x_8656 | |
a_8650 = {tmp_10452, tmp_10451} | |
end | |
local x_8658 = a_8650[1] | |
local y_8659 = a_8650[2] | |
a_8649 = x_8658 << y_8659 | |
end | |
local x_8661 = a_8649 | |
local tmp_10453 = x_8661 | |
a_8628 = {tmp_10453, lo_2564} | |
end | |
local x_8630 = a_8628[1] | |
local y_8631 = a_8628[2] | |
local a_8632 | |
do | |
local a_8633 | |
do | |
local a_8634 = x_8630 | |
local x_8636 = a_8634 | |
local tmp_10455 = x_8636 | |
local a_8637 = y_8631 | |
local x_8639 = a_8637 | |
local tmp_10454 = x_8639 | |
a_8633 = {tmp_10455, tmp_10454} | |
end | |
local x_8641 = a_8633[1] | |
local y_8642 = a_8633[2] | |
a_8632 = x_8641 | y_8642 | |
end | |
local x_8644 = a_8632 | |
v_2566 = x_8644 | |
end | |
local hi_2567 | |
do | |
local tmp_10457 | |
do | |
local a_8679 | |
do | |
local a_8684 | |
do | |
local x_8687 = wordSize_1007 | |
a_8684 = x_8687 | |
end | |
local x_8689 = a_8684 | |
local tmp_10456 = x_8689 | |
a_8679 = {tmp_10456, minor_2556} | |
end | |
local x_8681 = a_8679[1] | |
local y_8682 = a_8679[2] | |
tmp_10457 = x_8681 - y_8682 | |
end | |
local a_8666 | |
do | |
local a_8667 | |
do | |
local x_8670 = w_2565 | |
local tmp_10459 = x_8670 | |
local x_8673 = tmp_10457 | |
local tmp_10458 = x_8673 | |
a_8667 = {tmp_10459, tmp_10458} | |
end | |
local x_8675 = a_8667[1] | |
local y_8676 = a_8667[2] | |
a_8666 = x_8675 >> y_8676 | |
end | |
local x_8678 = a_8666 | |
hi_2567 = x_8678 | |
end | |
local a_8695 | |
do | |
local a_8705 | |
do | |
local x_8708 = major_2555 | |
local tmp_10461 = x_8708 | |
local a_8709 = 0x0 | |
local x_8711 = a_8709 | |
local tmp_10460 = x_8711 | |
a_8705 = {tmp_10461, tmp_10460} | |
end | |
local x_8713 = a_8705[1] | |
local y_8714 = a_8705[2] | |
local tmp124 = x_8713 < y_8714 | |
local tmp_10462 | |
if tmp124 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8715 | |
do | |
local x_8718 = major_2555 | |
a_8715 = x_8718 | |
end | |
local x_8720 = a_8715 | |
tmp_10462 = x_8720 | |
end | |
local x_8702 = a_2562[2] | |
local tmp_10463 = __Int_add(x_8702, tmp_10462) | |
a_8695 = {arr_2560, tmp_10463, v_2566} | |
end | |
local arr_8697 = a_8695[1] | |
local i_8698 = a_8695[2] | |
local v_8699 = a_8695[3] | |
arr_8697[i_8698 + 1] = v_8699 | |
local tmp_10464 = 1 | |
local x_8723 = a_2562[2] | |
local tmp125 = __Int_add(x_8723, tmp_10464) | |
return loop_2561({hi_2567, tmp125}) | |
end | |
end | |
loop_2561({0x0, 0}) | |
return normalize_2409(arr_2560) | |
end | |
end | |
local RShiftAbs_2568 = function(a_2569) | |
local words_2571 = a_2569[1] | |
local amount_2570 = a_2569[2] | |
local major_2572 | |
do | |
local a_8725 | |
do | |
local a_8730 | |
do | |
local x_8733 = wordSize_1007 | |
a_8730 = x_8733 | |
end | |
local x_8735 = a_8730 | |
local tmp_10465 = x_8735 | |
a_8725 = {amount_2570, tmp_10465} | |
end | |
local x_8727 = a_8725[1] | |
local y_8728 = a_8725[2] | |
major_2572 = __Word_div(x_8727, y_8728) | |
end | |
local minor_2573 | |
do | |
local a_8736 | |
do | |
local a_8741 | |
do | |
local x_8744 = wordSize_1007 | |
a_8741 = x_8744 | |
end | |
local x_8746 = a_8741 | |
local tmp_10466 = x_8746 | |
a_8736 = {amount_2570, tmp_10466} | |
end | |
local x_8738 = a_8736[1] | |
local y_8739 = a_8736[2] | |
minor_2573 = __Word_mod(x_8738, y_8739) | |
end | |
local n_2574 | |
do | |
local tmp_10469, tmp_10470 | |
do | |
local a_8754 = words_2571 | |
tmp_10470 = a_8754.n | |
local a_8758 | |
do | |
local x_8761 = major_2572 | |
local tmp_10468 = x_8761 | |
local a_8762 = 0x0 | |
local x_8764 = a_8762 | |
local tmp_10467 = x_8764 | |
a_8758 = {tmp_10468, tmp_10467} | |
end | |
local x_8766 = a_8758[1] | |
local y_8767 = a_8758[2] | |
local tmp126 = x_8766 < y_8767 | |
if tmp126 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8768 | |
do | |
local x_8771 = major_2572 | |
a_8768 = x_8771 | |
end | |
local x_8773 = a_8768 | |
tmp_10469 = x_8773 | |
end | |
end | |
n_2574 = __Int_sub(tmp_10470, tmp_10469) | |
end | |
if minor_2573 == 0x0 then | |
local tmp128 = _VectorOrArray_tabulate({n_2574, function(i_2575) | |
local tmp_10474 | |
do | |
local a_8787 | |
do | |
local x_8790 = major_2572 | |
local tmp_10472 = x_8790 | |
local a_8791 = 0x0 | |
local x_8793 = a_8791 | |
local tmp_10471 = x_8793 | |
a_8787 = {tmp_10472, tmp_10471} | |
end | |
local x_8795 = a_8787[1] | |
local y_8796 = a_8787[2] | |
local tmp127 = x_8795 < y_8796 | |
local tmp_10473 | |
if tmp127 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8797 | |
do | |
local x_8800 = major_2572 | |
a_8797 = x_8800 | |
end | |
local x_8802 = a_8797 | |
tmp_10473 = x_8802 | |
end | |
tmp_10474 = __Int_add(i_2575, tmp_10473) | |
end | |
local vec_8780 = a_2569[1] | |
return vec_8780[tmp_10474 + 1] | |
end}) | |
local tmp129 = VectorSlice_1908["exists"](function(x_2576) | |
return (function(a_8812) | |
local x_8814 = a_8812[1] | |
local y_8815 = a_8812[2] | |
local a_8816 = x_8814 == y_8815 | |
return not a_8816 | |
end)({x_2576, 0x0}) | |
end) | |
local a_8820 | |
do | |
local x_8823 = major_2572 | |
local tmp_10476 = x_8823 | |
local a_8824 = 0x0 | |
local x_8826 = a_8824 | |
local tmp_10475 = x_8826 | |
a_8820 = {tmp_10476, tmp_10475} | |
end | |
local x_8828 = a_8820[1] | |
local y_8829 = a_8820[2] | |
local tmp130 = x_8828 < y_8829 | |
local tmp131 | |
if tmp130 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8830 | |
do | |
local x_8833 = major_2572 | |
a_8830 = x_8833 | |
end | |
local x_8835 = a_8830 | |
tmp131 = x_8835 | |
end | |
local tmp132 = SOME_385(tmp131) | |
local tmp133 = VectorSlice_1908["slice"]({words_2571, 0, tmp132}) | |
local tmp134 = tmp129(tmp133) | |
return {tmp128, tmp134} | |
else | |
local arr_2577 = _Array_array({n_2574, 0x0}) | |
local hasRemainder_2578 | |
do | |
local loop_2579 | |
loop_2579 = function(a_2580) | |
local hi_2582 = a_2580[1] | |
local tmp_10477 = 0 | |
local x_8838 = a_2580[2] | |
if x_8838 < tmp_10477 then | |
return (function(a_8849) | |
local x_8851 = a_8849[1] | |
local y_8852 = a_8849[2] | |
local a_8853 = x_8851 == y_8852 | |
return not a_8853 | |
end)({hi_2582, 0x0}) | |
else | |
local w_2583 | |
do | |
local tmp_10481 | |
do | |
local a_8869 | |
do | |
local x_8872 = major_2572 | |
local tmp_10479 = x_8872 | |
local a_8873 = 0x0 | |
local x_8875 = a_8873 | |
local tmp_10478 = x_8875 | |
a_8869 = {tmp_10479, tmp_10478} | |
end | |
local x_8877 = a_8869[1] | |
local y_8878 = a_8869[2] | |
local tmp135 = x_8877 < y_8878 | |
local tmp_10480 | |
if tmp135 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8879 | |
do | |
local x_8882 = major_2572 | |
a_8879 = x_8882 | |
end | |
local x_8884 = a_8879 | |
tmp_10480 = x_8884 | |
end | |
local x_8866 = a_2580[2] | |
tmp_10481 = __Int_add(x_8866, tmp_10480) | |
end | |
local vec_8862 = a_2569[1] | |
w_2583 = vec_8862[tmp_10481 + 1] | |
end | |
local v_2584 | |
do | |
local a_8885 | |
do | |
local a_8906 | |
do | |
local a_8907 | |
do | |
local x_8910 = w_2583 | |
local tmp_10483 = x_8910 | |
local x_8913 = minor_2573 | |
local tmp_10482 = x_8913 | |
a_8907 = {tmp_10483, tmp_10482} | |
end | |
local x_8915 = a_8907[1] | |
local y_8916 = a_8907[2] | |
a_8906 = x_8915 >> y_8916 | |
end | |
local x_8918 = a_8906 | |
local tmp_10484 = x_8918 | |
a_8885 = {tmp_10484, hi_2582} | |
end | |
local x_8887 = a_8885[1] | |
local y_8888 = a_8885[2] | |
local a_8889 | |
do | |
local a_8890 | |
do | |
local a_8891 = x_8887 | |
local x_8893 = a_8891 | |
local tmp_10486 = x_8893 | |
local a_8894 = y_8888 | |
local x_8896 = a_8894 | |
local tmp_10485 = x_8896 | |
a_8890 = {tmp_10486, tmp_10485} | |
end | |
local x_8898 = a_8890[1] | |
local y_8899 = a_8890[2] | |
a_8889 = x_8898 | y_8899 | |
end | |
local x_8901 = a_8889 | |
v_2584 = x_8901 | |
end | |
local lo_2585 | |
do | |
local tmp_10488 | |
do | |
local a_8936 | |
do | |
local a_8941 | |
do | |
local x_8944 = wordSize_1007 | |
a_8941 = x_8944 | |
end | |
local x_8946 = a_8941 | |
local tmp_10487 = x_8946 | |
a_8936 = {tmp_10487, minor_2573} | |
end | |
local x_8938 = a_8936[1] | |
local y_8939 = a_8936[2] | |
tmp_10488 = x_8938 - y_8939 | |
end | |
local a_8923 | |
do | |
local a_8924 | |
do | |
local x_8927 = w_2583 | |
local tmp_10490 = x_8927 | |
local x_8930 = tmp_10488 | |
local tmp_10489 = x_8930 | |
a_8924 = {tmp_10490, tmp_10489} | |
end | |
local x_8932 = a_8924[1] | |
local y_8933 = a_8924[2] | |
a_8923 = x_8932 << y_8933 | |
end | |
local x_8935 = a_8923 | |
lo_2585 = x_8935 | |
end | |
local i_8955 = a_2580[2] | |
arr_2577[i_8955 + 1] = v_2584 | |
local tmp_10491 = 1 | |
local x_8959 = a_2580[2] | |
local tmp136 = __Int_sub(x_8959, tmp_10491) | |
return loop_2579({lo_2585, tmp136}) | |
end | |
end | |
local tmp_10492 = 1 | |
local tmp137 = __Int_sub(n_2574, tmp_10492) | |
hasRemainder_2578 = loop_2579({0x0, tmp137}) | |
end | |
local hasRemainder_2586 | |
if hasRemainder_2578 then | |
hasRemainder_2586 = true | |
else | |
local tmp138 = VectorSlice_1908["exists"](function(x_2587) | |
return (function(a_8974) | |
local x_8976 = a_8974[1] | |
local y_8977 = a_8974[2] | |
local a_8978 = x_8976 == y_8977 | |
return not a_8978 | |
end)({x_2587, 0x0}) | |
end) | |
local a_8982 | |
do | |
local x_8985 = major_2572 | |
local tmp_10494 = x_8985 | |
local a_8986 = 0x0 | |
local x_8988 = a_8986 | |
local tmp_10493 = x_8988 | |
a_8982 = {tmp_10494, tmp_10493} | |
end | |
local x_8990 = a_8982[1] | |
local y_8991 = a_8982[2] | |
local tmp139 = x_8990 < y_8991 | |
local tmp140 | |
if tmp139 then | |
_raise(_Overflow, "mlbasis.sml:680:39") | |
else | |
local a_8992 | |
do | |
local x_8995 = major_2572 | |
a_8992 = x_8995 | |
end | |
local x_8997 = a_8992 | |
tmp140 = x_8997 | |
end | |
local tmp141 = SOME_385(tmp140) | |
local tmp142 = VectorSlice_1908["slice"]({words_2571, 0, tmp141}) | |
hasRemainder_2586 = tmp138(tmp142) | |
end | |
local tmp143 = normalize_2409(arr_2577) | |
return {tmp143, hasRemainder_2586} | |
end | |
end | |
local _LT_LT_2588 = function(a_2589) | |
if a_2589[1].tag == "ZERO" then | |
local z_2590 = a_2589[1] | |
return z_2590 | |
elseif a_2589[1].tag == "POSITIVE" then | |
local words_2592 = a_2589[1].payload | |
local amount_2591 = a_2589[2] | |
local tmp144 = LShiftAbs_2551({words_2592, amount_2591}) | |
return POSITIVE_2338(tmp144) | |
elseif a_2589[1].tag == "NEGATIVE" then | |
local words_2594 = a_2589[1].payload | |
local amount_2593 = a_2589[2] | |
local tmp145 = LShiftAbs_2551({words_2594, amount_2593}) | |
return NEGATIVE_2337(tmp145) | |
else | |
_raise(_Match, "int-inf.sml:365:5") | |
end | |
end | |
local _TILDE_GT_GT_2595 = function(a_2596) | |
if a_2596[1].tag == "ZERO" then | |
local z_2597 = a_2596[1] | |
return z_2597 | |
elseif a_2596[1].tag == "POSITIVE" then | |
local words_2599 = a_2596[1].payload | |
local amount_2598 = a_2596[2] | |
local tmp146 = RShiftAbs_2568({words_2599, amount_2598}) | |
return POSITIVE_2338(tmp146[1]) | |
elseif a_2596[1].tag == "NEGATIVE" then | |
local words_2601 = a_2596[1].payload | |
local amount_2600 = a_2596[2] | |
local x_2603, y_2602 | |
do | |
local exp_3371 = RShiftAbs_2568({words_2601, amount_2600}) | |
local x_2604 = exp_3371[1] | |
local y_2605 = exp_3371[2] | |
x_2603, y_2602 = table_unpack({x_2604, y_2605}, 1, 2) | |
end | |
local tmp147 | |
if y_2602 then | |
tmp147 = addAbs_2417({x_2603, { n = 1, 0x1 }}) | |
else | |
tmp147 = x_2603 | |
end | |
return NEGATIVE_2337(tmp147) | |
else | |
_raise(_Match, "int-inf.sml:369:5") | |
end | |
end | |
local clzWord_2606 = function(a_2607) | |
local loop_2609 | |
loop_2609 = function(a_2610) | |
local x_2612 = a_2610[1] | |
local n_2611 = a_2610[2] | |
if x_2612 == 0x0 then | |
return n_2611 | |
else | |
local tmp_10495 = 0x1 | |
local x_9000 = a_2610[1] | |
local a_9002 | |
do | |
local a_9003 | |
do | |
local a_9004 = x_9000 | |
local x_9006 = a_9004 | |
local tmp_10497 = x_9006 | |
local x_9009 = tmp_10495 | |
local tmp_10496 = x_9009 | |
a_9003 = {tmp_10497, tmp_10496} | |
end | |
local x_9011 = a_9003[1] | |
local y_9012 = a_9003[2] | |
a_9002 = x_9011 >> y_9012 | |
end | |
local x_9014 = a_9002 | |
local tmp_10498 = 1 | |
local x_9017 = a_2610[2] | |
local tmp148 = __Int_sub(x_9017, tmp_10498) | |
return loop_2609({x_9014, tmp148}) | |
end | |
end | |
return loop_2609({a_2607, wordSize_1007}) | |
end | |
local quot2_2613 = function(a_2614) | |
local u1_2617 = a_2614[1] | |
local v_2615 = a_2614[3] | |
local v__hi_2618 | |
do | |
local x_9021 = a_2614[3] | |
local a_9023 | |
do | |
local a_9024 | |
do | |
local a_9025 = x_9021 | |
local x_9027 = a_9025 | |
local tmp_10500 = x_9027 | |
local x_9030 = wordSize__2_2373 | |
local tmp_10499 = x_9030 | |
a_9024 = {tmp_10500, tmp_10499} | |
end | |
local x_9032 = a_9024[1] | |
local y_9033 = a_9024[2] | |
a_9023 = x_9032 >> y_9033 | |
end | |
local x_9035 = a_9023 | |
v__hi_2618 = x_9035 | |
end | |
local q1_2619 | |
do | |
local x_9038 = a_2614[1] | |
q1_2619 = __Word_div(x_9038, v__hi_2618) | |
end | |
local r1_2620 | |
do | |
local x_9042 = a_2614[1] | |
r1_2620 = __Word_mod(x_9042, v__hi_2618) | |
end | |
local q_2621 | |
do | |
local tmp_10508, tmp_10509 | |
do | |
local a_9048 | |
do | |
local a_9056 | |
do | |
local a_9057 | |
do | |
local x_9060 = q1_2619 | |
local tmp_10502 = x_9060 | |
local x_9063 = wordSize__2_2373 | |
local tmp_10501 = x_9063 | |
a_9057 = {tmp_10502, tmp_10501} | |
end | |
local x_9065 = a_9057[1] | |
local y_9066 = a_9057[2] | |
a_9056 = x_9065 << y_9066 | |
end | |
local x_9068 = a_9056 | |
local tmp_10507 = x_9068 | |
local a_9069 | |
do | |
local a_9077 | |
do | |
local a_9078 | |
do | |
local x_9081 = r1_2620 | |
local tmp_10504 = x_9081 | |
local x_9084 = wordSize__2_2373 | |
local tmp_10503 = x_9084 | |
a_9078 = {tmp_10504, tmp_10503} | |
end | |
local x_9086 = a_9078[1] | |
local y_9087 = a_9078[2] | |
a_9077 = x_9086 << y_9087 | |
end | |
local x_9089 = a_9077 | |
local tmp_10505 = x_9089 | |
a_9069 = {tmp_10505, v__hi_2618} | |
end | |
local x_9071 = a_9069[1] | |
local y_9072 = a_9069[2] | |
local tmp_10506 = __Word_div(x_9071, y_9072) | |
a_9048 = {tmp_10507, tmp_10506} | |
end | |
local x_9050 = a_9048[1] | |
local y_9051 = a_9048[2] | |
tmp_10509 = x_9050 + y_9051 | |
local x_9092 = a_2614[2] | |
local y_9093 = a_2614[3] | |
tmp_10508 = __Word_div(x_9092, y_9093) | |
end | |
q_2621 = tmp_10509 + tmp_10508 | |
end | |
local loop_2622 | |
loop_2622 = function(a_2623) | |
local x_9094 = 0x0 | |
local a_9095 | |
do | |
local a_9096 | |
do | |
local x_9099 = x_9094 | |
a_9096 = x_9099 | |
end | |
a_9095 = ~ a_9096 | |
end | |
local x_9103 = a_9095 | |
if a_2623 == x_9103 then | |
return a_2623 | |
else | |
local v0_2625, v1_2626 | |
do | |
local exp_3376 = mul2_2375({a_2623, v_2615}) | |
local v1_2628 = exp_3376["hi"] | |
local v0_2627 = exp_3376["lo"] | |
v0_2625, v1_2626 = table_unpack({v0_2627, v1_2628}, 1, 2) | |
end | |
local x_9106 = a_2614[1] | |
local tmp149 = __Word_LT(x_9106, v1_2626) | |
local tmp150 | |
if tmp149 then | |
tmp150 = true | |
elseif u1_2617 == v1_2626 then | |
local x_9110 = a_2614[2] | |
tmp150 = __Word_LT(x_9110, v0_2625) | |
else | |
tmp150 = false | |
end | |
if tmp150 then | |
local tmp_10510 = 0x1 | |
return loop_2622(a_2623 - tmp_10510) | |
else | |
local v0_PRIME_2629, v1_PRIME_2630 | |
do | |
local tmp_10511 = 0x1 | |
local exp_3377 = mul2_2375({a_2623 + tmp_10511, v_2615}) | |
local v1_PRIME_2632 = exp_3377["hi"] | |
local v0_PRIME_2631 = exp_3377["lo"] | |
v0_PRIME_2629, v1_PRIME_2630 = table_unpack({v0_PRIME_2631, v1_PRIME_2632}, 1, 2) | |
end | |
local y_9123 = a_2614[1] | |
local tmp151 = __Word_LT(v1_PRIME_2630, y_9123) | |
local tmp152 | |
if tmp151 then | |
tmp152 = true | |
elseif v1_PRIME_2630 == u1_2617 then | |
local a_9128 | |
do | |
local x_9131 = a_2614[2] | |
a_9128 = __Word_LT(x_9131, v0_PRIME_2629) | |
end | |
tmp152 = not a_9128 | |
else | |
tmp152 = false | |
end | |
if tmp152 then | |
local tmp_10512 = 0x1 | |
return loop_2622(a_2623 + tmp_10512) | |
else | |
return a_2623 | |
end | |
end | |
end | |
end | |
return loop_2622(q_2621) | |
end | |
local quotRemAbs_2639 = function(a_2640) | |
local words_2642 = a_2640[1] | |
local words_PRIME_2641 = a_2640[2] | |
local n_2643 | |
do | |
local a_9150 = words_PRIME_2641 | |
n_2643 = a_9150.n | |
end | |
local m_PRIME_2644 | |
do | |
local a_9156 = words_2642 | |
m_PRIME_2644 = a_9156.n | |
end | |
local m_2645 = __Int_sub(m_PRIME_2644, n_2643) | |
local tmp_10514 = 0 | |
if m_2645 < tmp_10514 then | |
return {{ n = 0 }, words_2642} | |
else | |
local offset_2646 | |
do | |
local tmp_10516 | |
do | |
local tmp_10515 = 1 | |
tmp_10516 = __Int_sub(n_2643, tmp_10515) | |
end | |
local vec_9180 = a_2640[2] | |
local x_9167 = clzWord_2606(vec_9180[tmp_10516 + 1]) | |
local a_9168 | |
do | |
local x_9171 = x_9167 | |
a_9168 = x_9171 | |
end | |
local x_9173 = a_9168 | |
offset_2646 = x_9173 | |
end | |
local words_2647 = LShiftAbs_2551({words_2642, offset_2646}) | |
local words_2648 = _VectorOrArray_tabulate({words_2647.n, function(i_2649) | |
return words_2647[i_2649 + 1] | |
end}) | |
local words_PRIME_2650 = LShiftAbs_2551({words_PRIME_2641, offset_2646}) | |
local tmp_10517 = 1 | |
local tmp153 = __Int_add(m_2645, tmp_10517) | |
local quotient_2651 = _Array_array({tmp153, 0x0}) | |
local loop_2652 | |
loop_2652 = function(a_2653) | |
local tmp_10518 = 0 | |
if a_2653 < tmp_10518 then | |
return nil | |
else | |
local tmp_10519, tmp_10520 | |
do | |
tmp_10520 = words_2648.n | |
tmp_10519 = __Int_add(a_2653, n_2643) | |
end | |
local u1_2655 | |
if tmp_10520 > tmp_10519 then | |
local tmp_10521 = __Int_add(a_2653, n_2643) | |
u1_2655 = words_2648[tmp_10521 + 1] | |
else | |
u1_2655 = 0x0 | |
end | |
local u0_2656 | |
do | |
local tmp_10524 | |
do | |
local tmp_10522, tmp_10523 | |
do | |
tmp_10523 = __Int_add(a_2653, n_2643) | |
tmp_10522 = 1 | |
end | |
tmp_10524 = __Int_sub(tmp_10523, tmp_10522) | |
end | |
u0_2656 = words_2648[tmp_10524 + 1] | |
end | |
local v_2657 | |
do | |
local tmp_10526 | |
do | |
local tmp_10525 = 1 | |
tmp_10526 = __Int_sub(n_2643, tmp_10525) | |
end | |
v_2657 = words_PRIME_2650[tmp_10526 + 1] | |
end | |
local q_PRIME_2659 | |
do | |
local q_9267, tmp_10528 | |
do | |
q_9267 = quot2_2613({u1_2655, u0_2656, v_2657}) | |
local tmp_10527 = q_9267 * v_2657 | |
tmp_10528 = u0_2656 - tmp_10527 | |
end | |
local r_PRIME_2658 | |
q_PRIME_2659, r_PRIME_2658 = table_unpack({q_9267, tmp_10528}, 1, 2) | |
end | |
local loop2_2662 | |
loop2_2662 = function(a_2663) | |
local w_2665 = mulAbsSingle_2477({words_PRIME_2650, a_2663}) | |
local tmp154 = ArraySlice_1996["slice"]({words_2648, a_2653, NONE_386}) | |
local ws_2666 = ArraySlice_1996["vector"](tmp154) | |
local exp_3383 = compareAbs_2396({ws_2666, w_2665}) | |
if exp_3383.tag == "LESS" then | |
local tmp_10529 = 0x1 | |
return loop2_2662(a_2663 - tmp_10529) | |
else | |
local d_2667 = subAbs_2435({ws_2666, w_2665}) | |
local l_2668 | |
l_2668 = function(a_2669) | |
local tmp_10530 = words_2648.n | |
if a_2669 >= tmp_10530 then | |
return nil | |
else | |
local tmp_10531 = 0x0 | |
words_2648[a_2669 + 1] = tmp_10531 | |
local tmp_10532 = 1 | |
local tmp155 = __Int_add(a_2669, tmp_10532) | |
return l_2668(tmp155) | |
end | |
end | |
local tmp_10533 = d_2667.n | |
local tmp156 = __Int_add(a_2653, tmp_10533) | |
l_2668(tmp156) | |
copyVec_1600({["src"] = d_2667, ["dst"] = words_2648, ["di"] = a_2653}) | |
return a_2663 | |
end | |
end | |
local q_2671 = loop2_2662(q_PRIME_2659) | |
quotient_2651[a_2653 + 1] = q_2671 | |
local tmp_10534 = 1 | |
local tmp157 = __Int_sub(a_2653, tmp_10534) | |
return loop_2652(tmp157) | |
end | |
end | |
loop_2652(m_2645) | |
local tmp158 = normalize_2409(quotient_2651) | |
local tmp159 = normalize_2409(words_2648) | |
local tmp160 = RShiftAbs_2568({tmp159, offset_2646}) | |
return {tmp158, tmp160[1]} | |
end | |
end | |
local div___2678 = function(a_2679) | |
if a_2679[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:475:22") | |
elseif a_2679[1].tag == "ZERO" then | |
local z_2680 = a_2679[1] | |
return z_2680 | |
else | |
local tmp161 | |
if a_2679[1].tag == "POSITIVE" then | |
tmp161 = a_2679[2].tag == "POSITIVE" | |
else | |
tmp161 = false | |
end | |
if tmp161 then | |
local words_2682 = a_2679[1].payload | |
local words_PRIME_2681 = a_2679[2].payload | |
local q_2683 | |
do | |
local exp_3388 = quotRemAbs_2639({words_2682, words_PRIME_2681}) | |
local q_2684 = exp_3388[1] | |
q_2683 = q_2684 | |
end | |
local a_9340 = q_2683 | |
if a_9340.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9340) | |
end | |
else | |
local tmp162 | |
if a_2679[1].tag == "POSITIVE" then | |
tmp162 = a_2679[2].tag == "NEGATIVE" | |
else | |
tmp162 = false | |
end | |
if tmp162 then | |
local words_2686 = a_2679[1].payload | |
local words_PRIME_2685 = a_2679[2].payload | |
local q_2688, r_2687 | |
do | |
local exp_3389 = quotRemAbs_2639({words_2686, words_PRIME_2685}) | |
local q_2689 = exp_3389[1] | |
local r_2690 = exp_3389[2] | |
q_2688, r_2687 = table_unpack({q_2689, r_2690}, 1, 2) | |
end | |
local tmp_10535, tmp_10536 | |
do | |
tmp_10536 = r_2687.n | |
tmp_10535 = 0 | |
end | |
if tmp_10536 > tmp_10535 then | |
local a_9356 = addAbs_2417({q_2688, { n = 1, 0x1 }}) | |
if a_9356.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9356) | |
end | |
elseif q_2688.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(q_2688) | |
end | |
else | |
local tmp163 | |
if a_2679[1].tag == "NEGATIVE" then | |
tmp163 = a_2679[2].tag == "POSITIVE" | |
else | |
tmp163 = false | |
end | |
if tmp163 then | |
local words_2692 = a_2679[1].payload | |
local words_PRIME_2691 = a_2679[2].payload | |
local q_2694, r_2693 | |
do | |
local exp_3390 = quotRemAbs_2639({words_2692, words_PRIME_2691}) | |
local q_2695 = exp_3390[1] | |
local r_2696 = exp_3390[2] | |
q_2694, r_2693 = table_unpack({q_2695, r_2696}, 1, 2) | |
end | |
local tmp_10537, tmp_10538 | |
do | |
tmp_10538 = r_2693.n | |
tmp_10537 = 0 | |
end | |
if tmp_10538 > tmp_10537 then | |
local a_9378 = addAbs_2417({q_2694, { n = 1, 0x1 }}) | |
if a_9378.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9378) | |
end | |
elseif q_2694.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(q_2694) | |
end | |
else | |
local tmp164 | |
if a_2679[1].tag == "NEGATIVE" then | |
tmp164 = a_2679[2].tag == "NEGATIVE" | |
else | |
tmp164 = false | |
end | |
if tmp164 then | |
local words_2698 = a_2679[1].payload | |
local words_PRIME_2697 = a_2679[2].payload | |
local q_2699 | |
do | |
local exp_3391 = quotRemAbs_2639({words_2698, words_PRIME_2697}) | |
local q_2700 = exp_3391[1] | |
q_2699 = q_2700 | |
end | |
local a_9390 = q_2699 | |
if a_9390.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9390) | |
end | |
else | |
_raise(_Match, "int-inf.sml:475:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local mod___2701 = function(a_2702) | |
if a_2702[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:496:22") | |
elseif a_2702[1].tag == "ZERO" then | |
local z_2703 = a_2702[1] | |
return z_2703 | |
else | |
local tmp165 | |
if a_2702[1].tag == "POSITIVE" then | |
tmp165 = a_2702[2].tag == "POSITIVE" | |
else | |
tmp165 = false | |
end | |
if tmp165 then | |
local words_2705 = a_2702[1].payload | |
local words_PRIME_2704 = a_2702[2].payload | |
local r_2706 | |
do | |
local exp_3393 = quotRemAbs_2639({words_2705, words_PRIME_2704}) | |
local r_2707 = exp_3393[2] | |
r_2706 = r_2707 | |
end | |
local a_9396 = r_2706 | |
if a_9396.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9396) | |
end | |
else | |
local tmp166 | |
if a_2702[1].tag == "POSITIVE" then | |
tmp166 = a_2702[2].tag == "NEGATIVE" | |
else | |
tmp166 = false | |
end | |
if tmp166 then | |
local words_2709 = a_2702[1].payload | |
local words_PRIME_2708 = a_2702[2].payload | |
local r_2710 | |
do | |
local exp_3394 = quotRemAbs_2639({words_2709, words_PRIME_2708}) | |
local r_2711 = exp_3394[2] | |
r_2710 = r_2711 | |
end | |
local tmp_10539, tmp_10540 | |
do | |
local a_9409 = r_2710 | |
tmp_10540 = a_9409.n | |
tmp_10539 = 0 | |
end | |
if tmp_10540 > tmp_10539 then | |
local a_9412 = subAbs_2435({words_PRIME_2708, r_2710}) | |
if a_9412.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9412) | |
end | |
else | |
return ZERO_2339 | |
end | |
else | |
local tmp167 | |
if a_2702[1].tag == "NEGATIVE" then | |
tmp167 = a_2702[2].tag == "POSITIVE" | |
else | |
tmp167 = false | |
end | |
if tmp167 then | |
local words_2713 = a_2702[1].payload | |
local words_PRIME_2712 = a_2702[2].payload | |
local r_2714 | |
do | |
local exp_3395 = quotRemAbs_2639({words_2713, words_PRIME_2712}) | |
local r_2715 = exp_3395[2] | |
r_2714 = r_2715 | |
end | |
local tmp_10541, tmp_10542 | |
do | |
local a_9425 = r_2714 | |
tmp_10542 = a_9425.n | |
tmp_10541 = 0 | |
end | |
if tmp_10542 > tmp_10541 then | |
local a_9428 = subAbs_2435({words_PRIME_2712, r_2714}) | |
if a_9428.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9428) | |
end | |
else | |
return ZERO_2339 | |
end | |
else | |
local tmp168 | |
if a_2702[1].tag == "NEGATIVE" then | |
tmp168 = a_2702[2].tag == "NEGATIVE" | |
else | |
tmp168 = false | |
end | |
if tmp168 then | |
local words_2717 = a_2702[1].payload | |
local words_PRIME_2716 = a_2702[2].payload | |
local r_2718 | |
do | |
local exp_3396 = quotRemAbs_2639({words_2717, words_PRIME_2716}) | |
local r_2719 = exp_3396[2] | |
r_2718 = r_2719 | |
end | |
local a_9434 = r_2718 | |
if a_9434.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9434) | |
end | |
else | |
_raise(_Match, "int-inf.sml:496:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local divMod_2720 = function(a_2721) | |
if a_2721[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:517:24") | |
elseif a_2721[1].tag == "ZERO" then | |
local z_2722 = a_2721[1] | |
return {z_2722, z_2722} | |
else | |
local tmp169 | |
if a_2721[1].tag == "POSITIVE" then | |
tmp169 = a_2721[2].tag == "POSITIVE" | |
else | |
tmp169 = false | |
end | |
if tmp169 then | |
local words_2724 = a_2721[1].payload | |
local words_PRIME_2723 = a_2721[2].payload | |
local q_2726, r_2725 | |
do | |
local exp_3398 = quotRemAbs_2639({words_2724, words_PRIME_2723}) | |
local q_2727 = exp_3398[1] | |
local r_2728 = exp_3398[2] | |
q_2726, r_2725 = table_unpack({q_2727, r_2728}, 1, 2) | |
end | |
local tmp170 | |
if q_2726.n == 0 then | |
tmp170 = ZERO_2339 | |
else | |
tmp170 = POSITIVE_2338(q_2726) | |
end | |
local tmp171 | |
if r_2725.n == 0 then | |
tmp171 = ZERO_2339 | |
else | |
tmp171 = POSITIVE_2338(r_2725) | |
end | |
return {tmp170, tmp171} | |
else | |
local tmp172 | |
if a_2721[1].tag == "POSITIVE" then | |
tmp172 = a_2721[2].tag == "NEGATIVE" | |
else | |
tmp172 = false | |
end | |
if tmp172 then | |
local words_2730 = a_2721[1].payload | |
local words_PRIME_2729 = a_2721[2].payload | |
local q_2732, r_2731 | |
do | |
local exp_3399 = quotRemAbs_2639({words_2730, words_PRIME_2729}) | |
local q_2733 = exp_3399[1] | |
local r_2734 = exp_3399[2] | |
q_2732, r_2731 = table_unpack({q_2733, r_2734}, 1, 2) | |
end | |
local tmp_10543, tmp_10544 | |
do | |
tmp_10544 = r_2731.n | |
tmp_10543 = 0 | |
end | |
if tmp_10544 > tmp_10543 then | |
local a_9462 = addAbs_2417({q_2732, { n = 1, 0x1 }}) | |
local tmp173 | |
if a_9462.n == 0 then | |
tmp173 = ZERO_2339 | |
else | |
tmp173 = NEGATIVE_2337(a_9462) | |
end | |
local a_9468 = subAbs_2435({words_PRIME_2729, r_2731}) | |
local tmp174 | |
if a_9468.n == 0 then | |
tmp174 = ZERO_2339 | |
else | |
tmp174 = NEGATIVE_2337(a_9468) | |
end | |
return {tmp173, tmp174} | |
else | |
local tmp175 | |
if q_2732.n == 0 then | |
tmp175 = ZERO_2339 | |
else | |
tmp175 = NEGATIVE_2337(q_2732) | |
end | |
return {tmp175, ZERO_2339} | |
end | |
else | |
local tmp176 | |
if a_2721[1].tag == "NEGATIVE" then | |
tmp176 = a_2721[2].tag == "POSITIVE" | |
else | |
tmp176 = false | |
end | |
if tmp176 then | |
local words_2736 = a_2721[1].payload | |
local words_PRIME_2735 = a_2721[2].payload | |
local q_2738, r_2737 | |
do | |
local exp_3400 = quotRemAbs_2639({words_2736, words_PRIME_2735}) | |
local q_2739 = exp_3400[1] | |
local r_2740 = exp_3400[2] | |
q_2738, r_2737 = table_unpack({q_2739, r_2740}, 1, 2) | |
end | |
local tmp_10545, tmp_10546 | |
do | |
tmp_10546 = r_2737.n | |
tmp_10545 = 0 | |
end | |
if tmp_10546 > tmp_10545 then | |
local a_9490 = addAbs_2417({q_2738, { n = 1, 0x1 }}) | |
local tmp177 | |
if a_9490.n == 0 then | |
tmp177 = ZERO_2339 | |
else | |
tmp177 = NEGATIVE_2337(a_9490) | |
end | |
local a_9496 = subAbs_2435({words_PRIME_2735, r_2737}) | |
local tmp178 | |
if a_9496.n == 0 then | |
tmp178 = ZERO_2339 | |
else | |
tmp178 = POSITIVE_2338(a_9496) | |
end | |
return {tmp177, tmp178} | |
else | |
local tmp179 | |
if q_2738.n == 0 then | |
tmp179 = ZERO_2339 | |
else | |
tmp179 = NEGATIVE_2337(q_2738) | |
end | |
return {tmp179, ZERO_2339} | |
end | |
else | |
local tmp180 | |
if a_2721[1].tag == "NEGATIVE" then | |
tmp180 = a_2721[2].tag == "NEGATIVE" | |
else | |
tmp180 = false | |
end | |
if tmp180 then | |
local words_2742 = a_2721[1].payload | |
local words_PRIME_2741 = a_2721[2].payload | |
local q_2744, r_2743 | |
do | |
local exp_3401 = quotRemAbs_2639({words_2742, words_PRIME_2741}) | |
local q_2745 = exp_3401[1] | |
local r_2746 = exp_3401[2] | |
q_2744, r_2743 = table_unpack({q_2745, r_2746}, 1, 2) | |
end | |
local tmp181 | |
if q_2744.n == 0 then | |
tmp181 = ZERO_2339 | |
else | |
tmp181 = NEGATIVE_2337(q_2744) | |
end | |
local tmp182 | |
if r_2743.n == 0 then | |
tmp182 = ZERO_2339 | |
else | |
tmp182 = POSITIVE_2338(r_2743) | |
end | |
return {tmp181, tmp182} | |
else | |
_raise(_Match, "int-inf.sml:517:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local quot_2747 = function(a_2748) | |
if a_2748[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:538:22") | |
elseif a_2748[1].tag == "ZERO" then | |
local z_2749 = a_2748[1] | |
return z_2749 | |
else | |
local tmp183 | |
if a_2748[1].tag == "POSITIVE" then | |
tmp183 = a_2748[2].tag == "POSITIVE" | |
else | |
tmp183 = false | |
end | |
if tmp183 then | |
local words_2751 = a_2748[1].payload | |
local words_PRIME_2750 = a_2748[2].payload | |
local q_2752 | |
do | |
local exp_3403 = quotRemAbs_2639({words_2751, words_PRIME_2750}) | |
local q_2753 = exp_3403[1] | |
q_2752 = q_2753 | |
end | |
local a_9520 = q_2752 | |
if a_9520.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9520) | |
end | |
else | |
local tmp184 | |
if a_2748[1].tag == "POSITIVE" then | |
tmp184 = a_2748[2].tag == "NEGATIVE" | |
else | |
tmp184 = false | |
end | |
if tmp184 then | |
local words_2755 = a_2748[1].payload | |
local words_PRIME_2754 = a_2748[2].payload | |
local q_2756 | |
do | |
local exp_3404 = quotRemAbs_2639({words_2755, words_PRIME_2754}) | |
local q_2757 = exp_3404[1] | |
q_2756 = q_2757 | |
end | |
local a_9526 = q_2756 | |
if a_9526.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9526) | |
end | |
else | |
local tmp185 | |
if a_2748[1].tag == "NEGATIVE" then | |
tmp185 = a_2748[2].tag == "POSITIVE" | |
else | |
tmp185 = false | |
end | |
if tmp185 then | |
local words_2759 = a_2748[1].payload | |
local words_PRIME_2758 = a_2748[2].payload | |
local q_2760 | |
do | |
local exp_3405 = quotRemAbs_2639({words_2759, words_PRIME_2758}) | |
local q_2761 = exp_3405[1] | |
q_2760 = q_2761 | |
end | |
local a_9532 = q_2760 | |
if a_9532.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9532) | |
end | |
else | |
local tmp186 | |
if a_2748[1].tag == "NEGATIVE" then | |
tmp186 = a_2748[2].tag == "NEGATIVE" | |
else | |
tmp186 = false | |
end | |
if tmp186 then | |
local words_2763 = a_2748[1].payload | |
local words_PRIME_2762 = a_2748[2].payload | |
local q_2764 | |
do | |
local exp_3406 = quotRemAbs_2639({words_2763, words_PRIME_2762}) | |
local q_2765 = exp_3406[1] | |
q_2764 = q_2765 | |
end | |
local a_9538 = q_2764 | |
if a_9538.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9538) | |
end | |
else | |
_raise(_Match, "int-inf.sml:538:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local rem_2766 = function(a_2767) | |
if a_2767[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:553:21") | |
elseif a_2767[1].tag == "ZERO" then | |
local z_2768 = a_2767[1] | |
return z_2768 | |
else | |
local tmp187 | |
if a_2767[1].tag == "POSITIVE" then | |
tmp187 = a_2767[2].tag == "POSITIVE" | |
else | |
tmp187 = false | |
end | |
if tmp187 then | |
local words_2770 = a_2767[1].payload | |
local words_PRIME_2769 = a_2767[2].payload | |
local r_2771 | |
do | |
local exp_3408 = quotRemAbs_2639({words_2770, words_PRIME_2769}) | |
local r_2772 = exp_3408[2] | |
r_2771 = r_2772 | |
end | |
local a_9544 = r_2771 | |
if a_9544.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9544) | |
end | |
else | |
local tmp188 | |
if a_2767[1].tag == "POSITIVE" then | |
tmp188 = a_2767[2].tag == "NEGATIVE" | |
else | |
tmp188 = false | |
end | |
if tmp188 then | |
local words_2774 = a_2767[1].payload | |
local words_PRIME_2773 = a_2767[2].payload | |
local r_2775 | |
do | |
local exp_3409 = quotRemAbs_2639({words_2774, words_PRIME_2773}) | |
local r_2776 = exp_3409[2] | |
r_2775 = r_2776 | |
end | |
local a_9550 = r_2775 | |
if a_9550.n == 0 then | |
return ZERO_2339 | |
else | |
return POSITIVE_2338(a_9550) | |
end | |
else | |
local tmp189 | |
if a_2767[1].tag == "NEGATIVE" then | |
tmp189 = a_2767[2].tag == "POSITIVE" | |
else | |
tmp189 = false | |
end | |
if tmp189 then | |
local words_2778 = a_2767[1].payload | |
local words_PRIME_2777 = a_2767[2].payload | |
local r_2779 | |
do | |
local exp_3410 = quotRemAbs_2639({words_2778, words_PRIME_2777}) | |
local r_2780 = exp_3410[2] | |
r_2779 = r_2780 | |
end | |
local a_9556 = r_2779 | |
if a_9556.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9556) | |
end | |
else | |
local tmp190 | |
if a_2767[1].tag == "NEGATIVE" then | |
tmp190 = a_2767[2].tag == "NEGATIVE" | |
else | |
tmp190 = false | |
end | |
if tmp190 then | |
local words_2782 = a_2767[1].payload | |
local words_PRIME_2781 = a_2767[2].payload | |
local r_2783 | |
do | |
local exp_3411 = quotRemAbs_2639({words_2782, words_PRIME_2781}) | |
local r_2784 = exp_3411[2] | |
r_2783 = r_2784 | |
end | |
local a_9562 = r_2783 | |
if a_9562.n == 0 then | |
return ZERO_2339 | |
else | |
return NEGATIVE_2337(a_9562) | |
end | |
else | |
_raise(_Match, "int-inf.sml:553:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local quotRem_2785 = function(a_2786) | |
if a_2786[2].tag == "ZERO" then | |
_raise(_Div, "int-inf.sml:568:25") | |
elseif a_2786[1].tag == "ZERO" then | |
local z_2787 = a_2786[1] | |
return {z_2787, z_2787} | |
else | |
local tmp191 | |
if a_2786[1].tag == "POSITIVE" then | |
tmp191 = a_2786[2].tag == "POSITIVE" | |
else | |
tmp191 = false | |
end | |
if tmp191 then | |
local words_2789 = a_2786[1].payload | |
local words_PRIME_2788 = a_2786[2].payload | |
local q_2791, r_2790 | |
do | |
local exp_3413 = quotRemAbs_2639({words_2789, words_PRIME_2788}) | |
local q_2792 = exp_3413[1] | |
local r_2793 = exp_3413[2] | |
q_2791, r_2790 = table_unpack({q_2792, r_2793}, 1, 2) | |
end | |
local tmp192 | |
if q_2791.n == 0 then | |
tmp192 = ZERO_2339 | |
else | |
tmp192 = POSITIVE_2338(q_2791) | |
end | |
local tmp193 | |
if r_2790.n == 0 then | |
tmp193 = ZERO_2339 | |
else | |
tmp193 = POSITIVE_2338(r_2790) | |
end | |
return {tmp192, tmp193} | |
else | |
local tmp194 | |
if a_2786[1].tag == "POSITIVE" then | |
tmp194 = a_2786[2].tag == "NEGATIVE" | |
else | |
tmp194 = false | |
end | |
if tmp194 then | |
local words_2795 = a_2786[1].payload | |
local words_PRIME_2794 = a_2786[2].payload | |
local q_2797, r_2796 | |
do | |
local exp_3414 = quotRemAbs_2639({words_2795, words_PRIME_2794}) | |
local q_2798 = exp_3414[1] | |
local r_2799 = exp_3414[2] | |
q_2797, r_2796 = table_unpack({q_2798, r_2799}, 1, 2) | |
end | |
local tmp195 | |
if q_2797.n == 0 then | |
tmp195 = ZERO_2339 | |
else | |
tmp195 = NEGATIVE_2337(q_2797) | |
end | |
local tmp196 | |
if r_2796.n == 0 then | |
tmp196 = ZERO_2339 | |
else | |
tmp196 = POSITIVE_2338(r_2796) | |
end | |
return {tmp195, tmp196} | |
else | |
local tmp197 | |
if a_2786[1].tag == "NEGATIVE" then | |
tmp197 = a_2786[2].tag == "POSITIVE" | |
else | |
tmp197 = false | |
end | |
if tmp197 then | |
local words_2801 = a_2786[1].payload | |
local words_PRIME_2800 = a_2786[2].payload | |
local q_2803, r_2802 | |
do | |
local exp_3415 = quotRemAbs_2639({words_2801, words_PRIME_2800}) | |
local q_2804 = exp_3415[1] | |
local r_2805 = exp_3415[2] | |
q_2803, r_2802 = table_unpack({q_2804, r_2805}, 1, 2) | |
end | |
local tmp198 | |
if q_2803.n == 0 then | |
tmp198 = ZERO_2339 | |
else | |
tmp198 = NEGATIVE_2337(q_2803) | |
end | |
local tmp199 | |
if r_2802.n == 0 then | |
tmp199 = ZERO_2339 | |
else | |
tmp199 = NEGATIVE_2337(r_2802) | |
end | |
return {tmp198, tmp199} | |
else | |
local tmp200 | |
if a_2786[1].tag == "NEGATIVE" then | |
tmp200 = a_2786[2].tag == "NEGATIVE" | |
else | |
tmp200 = false | |
end | |
if tmp200 then | |
local words_2807 = a_2786[1].payload | |
local words_PRIME_2806 = a_2786[2].payload | |
local q_2809, r_2808 | |
do | |
local exp_3416 = quotRemAbs_2639({words_2807, words_PRIME_2806}) | |
local q_2810 = exp_3416[1] | |
local r_2811 = exp_3416[2] | |
q_2809, r_2808 = table_unpack({q_2810, r_2811}, 1, 2) | |
end | |
local tmp201 | |
if q_2809.n == 0 then | |
tmp201 = ZERO_2339 | |
else | |
tmp201 = POSITIVE_2338(q_2809) | |
end | |
local tmp202 | |
if r_2808.n == 0 then | |
tmp202 = ZERO_2339 | |
else | |
tmp202 = NEGATIVE_2337(r_2808) | |
end | |
return {tmp201, tmp202} | |
else | |
_raise(_Match, "int-inf.sml:568:5") | |
end | |
end | |
end | |
end | |
end | |
end | |
local min_2812 = function(a_2813) | |
local x_2815 = a_2813[1] | |
local y_2814 = a_2813[2] | |
local tmp203 = LT_2539({x_2815, y_2814}) | |
if tmp203 then | |
return x_2815 | |
else | |
return y_2814 | |
end | |
end | |
local max_2816 = function(a_2817) | |
local x_2819 = a_2817[1] | |
local y_2818 = a_2817[2] | |
local tmp204 = LT_2539({x_2819, y_2818}) | |
if tmp204 then | |
return y_2818 | |
else | |
return x_2819 | |
end | |
end | |
local sign_2820 = function(a_2821) | |
if a_2821.tag == "ZERO" then | |
return 0 | |
elseif a_2821.tag == "POSITIVE" then | |
return 1 | |
elseif a_2821.tag == "NEGATIVE" then | |
return -1 | |
else | |
_raise(_Match, "int-inf.sml:593:5") | |
end | |
end | |
local sameSign_2822 = function(a_2823) | |
local tmp205 | |
if a_2823[1].tag == "ZERO" then | |
tmp205 = a_2823[2].tag == "ZERO" | |
else | |
tmp205 = false | |
end | |
if tmp205 then | |
return true | |
else | |
local tmp206 | |
if a_2823[1].tag == "POSITIVE" then | |
tmp206 = a_2823[2].tag == "POSITIVE" | |
else | |
tmp206 = false | |
end | |
if tmp206 then | |
return true | |
else | |
local tmp207 | |
if a_2823[1].tag == "NEGATIVE" then | |
tmp207 = a_2823[2].tag == "NEGATIVE" | |
else | |
tmp207 = false | |
end | |
if tmp207 then | |
return true | |
else | |
return false | |
end | |
end | |
end | |
end | |
local notb_2824 = function(a_2825) | |
local tmp208 = fromInt_2345(1) | |
local a_9616 = add_2502({a_2825, tmp208}) | |
if a_9616.tag == "POSITIVE" then | |
local words_9618 = a_9616.payload | |
return NEGATIVE_2337(words_9618) | |
elseif a_9616.tag == "NEGATIVE" then | |
local words_9619 = a_9616.payload | |
return POSITIVE_2338(words_9619) | |
else | |
return a_9616 | |
end | |
end | |
local fmtHexAbs_2843, toString_2839 | |
do | |
local ten__to__9_2831 = POSITIVE_2338({ n = 1, 0x3B9ACA00 }) | |
local toStringAbs_2832 | |
toStringAbs_2832 = function(a_2833) | |
if a_2833.tag == "ZERO" then | |
return "" | |
else | |
local tmp209 = LT_2539({a_2833, ten__to__9_2831}) | |
if tmp209 then | |
local a_9641 | |
do | |
local tmp_10550 = "%u" | |
local x_9658 = toInt_2340(a_2833) | |
local a_9659 | |
do | |
local x_9662 = x_9658 | |
a_9659 = x_9662 | |
end | |
local x_9664 = a_9659 | |
local tmp_10549 = x_9664 | |
a_9641 = {tmp_10550, tmp_10549} | |
end | |
local f_9643 = a_9641[1] | |
local x_9644 = a_9641[2] | |
local a_9645 | |
do | |
local tmp_10551, tmp_10552 | |
do | |
local a_9647 = f_9643 | |
local x_9649 = a_9647 | |
local a_9650 = x_9644 | |
local x_9652 = a_9650 | |
tmp_10552 = table_pack(string_format(x_9649, x_9652)) | |
tmp_10551 = 0 | |
end | |
a_9645 = tmp_10552[tmp_10551 + 1] | |
end | |
local x_9657 = a_9645 | |
return x_9657 | |
else | |
local q_2836, r_2835 | |
do | |
local exp_3424 = quotRem_2785({a_2833, ten__to__9_2831}) | |
local q_2837 = exp_3424[1] | |
local r_2838 = exp_3424[2] | |
q_2836, r_2835 = table_unpack({q_2837, r_2838}, 1, 2) | |
end | |
local a_9665 | |
do | |
local tmp_10558 = toStringAbs_2832(q_2836) | |
local a_9669 | |
do | |
local tmp_10554 = "%09u" | |
local x_9686 = toInt_2340(r_2835) | |
local a_9687 | |
do | |
local x_9690 = x_9686 | |
a_9687 = x_9690 | |
end | |
local x_9692 = a_9687 | |
local tmp_10553 = x_9692 | |
a_9669 = {tmp_10554, tmp_10553} | |
end | |
local f_9671 = a_9669[1] | |
local x_9672 = a_9669[2] | |
local a_9673 | |
do | |
local tmp_10555, tmp_10556 | |
do | |
local a_9675 = f_9671 | |
local x_9677 = a_9675 | |
local a_9678 = x_9672 | |
local x_9680 = a_9678 | |
tmp_10556 = table_pack(string_format(x_9677, x_9680)) | |
tmp_10555 = 0 | |
end | |
a_9673 = tmp_10556[tmp_10555 + 1] | |
end | |
local x_9685 = a_9673 | |
local tmp_10557 = x_9685 | |
a_9665 = {tmp_10558, tmp_10557} | |
end | |
local x_9667 = a_9665[1] | |
local y_9668 = a_9665[2] | |
return x_9667 .. y_9668 | |
end | |
end | |
end | |
toString_2839 = function(a_2840) | |
if a_2840.tag == "ZERO" then | |
return "0" | |
elseif a_2840.tag == "POSITIVE" then | |
return toStringAbs_2832(a_2840) | |
elseif a_2840.tag == "NEGATIVE" then | |
local words_2842 = a_2840.payload | |
local tmp_10559, tmp_10560 | |
do | |
tmp_10560 = "~" | |
local tmp210 = POSITIVE_2338(words_2842) | |
tmp_10559 = toStringAbs_2832(tmp210) | |
end | |
return tmp_10560 .. tmp_10559 | |
else | |
_raise(_Match, "int-inf.sml:616:5") | |
end | |
end | |
fmtHexAbs_2843 = function(a_2844) | |
local n_2846 = a_2844.n | |
local last_2847 | |
do | |
local tmp_10562 | |
do | |
local tmp_10561 = 1 | |
tmp_10562 = __Int_sub(n_2846, tmp_10561) | |
end | |
last_2847 = a_2844[tmp_10562 + 1] | |
end | |
local lasts_2848 | |
do | |
local tmp_10563 = "%X" | |
local a_9719 | |
do | |
local tmp_10564, tmp_10565 | |
do | |
local x_9723 = tmp_10563 | |
local x_9726 = last_2847 | |
tmp_10565 = table_pack(string_format(x_9723, x_9726)) | |
tmp_10564 = 0 | |
end | |
a_9719 = tmp_10565[tmp_10564 + 1] | |
end | |
local x_9731 = a_9719 | |
lasts_2848 = x_9731 | |
end | |
local middlefmt_2849 | |
do | |
local tmp_10569, tmp_10570 | |
do | |
local tmp_10567, tmp_10568 | |
do | |
tmp_10568 = "%0" | |
local tmp_10566 = 4 | |
local tmp211 = __Int_div(wordSize_1007, tmp_10566) | |
tmp_10567 = toString_992(tmp211) | |
end | |
tmp_10570 = tmp_10568 .. tmp_10567 | |
tmp_10569 = "X" | |
end | |
middlefmt_2849 = tmp_10570 .. tmp_10569 | |
end | |
local loop_2850 | |
loop_2850 = function(a_2851) | |
local xs_2853 = a_2851[1] | |
local tmp_10572 | |
do | |
local tmp_10571 = 1 | |
tmp_10572 = __Int_sub(n_2846, tmp_10571) | |
end | |
local x_9746 = a_2851[2] | |
if x_9746 >= tmp_10572 then | |
return _cons({lasts_2848, xs_2853}) | |
else | |
local tmp_10573 | |
do | |
local i_9776 = a_2851[2] | |
tmp_10573 = a_2844[i_9776 + 1] | |
end | |
local a_9756 | |
do | |
local tmp_10574, tmp_10575 | |
do | |
local x_9760 = middlefmt_2849 | |
local x_9763 = tmp_10573 | |
tmp_10575 = table_pack(string_format(x_9760, x_9763)) | |
tmp_10574 = 0 | |
end | |
a_9756 = tmp_10575[tmp_10574 + 1] | |
end | |
local x_9768 = a_9756 | |
local tmp212 = _cons({x_9768, xs_2853}) | |
local tmp_10576 = 1 | |
local x_9779 = a_2851[2] | |
local tmp213 = __Int_add(x_9779, tmp_10576) | |
return loop_2850({tmp212, tmp213}) | |
end | |
end | |
local a_9781 = loop_2850({_nil, 0}) | |
local a_9785 = _VectorOrArray_fromList(a_9781) | |
local x_9787 = a_9785 | |
local result_9784 = table_pack(concat_688(x_9787)) | |
local a_9788 = sub_547({result_9784, 0}) | |
local x_9790 = a_9788 | |
return x_9790 | |
end | |
end | |
local fmt_2854 = function(a_2855) | |
return function(a_2856) | |
if a_2855.tag == "BIN" then | |
local tmp214 = _Fail("StringCvt.BIN: not implemented yet") | |
_raise(tmp214, "int-inf.sml:633:27") | |
elseif a_2855.tag == "OCT" then | |
local tmp215 = _Fail("StringCvt.OCT: not implemented yet") | |
_raise(tmp215, "int-inf.sml:634:27") | |
elseif a_2855.tag == "DEC" then | |
return toString_2839(a_2856) | |
elseif a_2855.tag == "HEX" then | |
if a_2856.tag == "ZERO" then | |
return "0" | |
elseif a_2856.tag == "POSITIVE" then | |
local words_2861 = a_2856.payload | |
return fmtHexAbs_2843(words_2861) | |
elseif a_2856.tag == "NEGATIVE" then | |
local words_2862 = a_2856.payload | |
local tmp_10577, tmp_10578 | |
do | |
tmp_10578 = "~" | |
tmp_10577 = fmtHexAbs_2843(words_2862) | |
end | |
return tmp_10578 .. tmp_10577 | |
else | |
_raise(_Match, "int-inf.sml:636:28") | |
end | |
else | |
_raise(_Match, "int-inf.sml:633:5") | |
end | |
end | |
end | |
local abs_2873 = function(a_2874) | |
if a_2874.tag == "NEGATIVE" then | |
local words_2875 = a_2874.payload | |
return POSITIVE_2338(words_2875) | |
else | |
return a_2874 | |
end | |
end | |
local _TILDE_2877 = negate_2497 | |
local _LT_EQ_2881 = function(a_2882) | |
local x_2884 = a_2882[1] | |
local y_2883 = a_2882[2] | |
local a_9795 = LT_2539({y_2883, x_2884}) | |
return not a_9795 | |
end | |
local _GT_2885 = function(a_2886) | |
local x_2888 = a_2886[1] | |
local y_2887 = a_2886[2] | |
return LT_2539({y_2887, x_2888}) | |
end | |
local _GT_EQ_2889 = function(a_2890) | |
local x_2892 = a_2890[1] | |
local y_2891 = a_2890[2] | |
local a_9798 = LT_2539({x_2892, y_2891}) | |
return not a_9798 | |
end | |
local IntInf_2901 = {EQUALint_2895, {["*"] = mul_2527, ["+"] = add_2502, ["-"] = sub_2514, ["<"] = LT_2539, ["<<"] = _LT_LT_2588, ["<="] = _LT_EQ_2881, [">"] = _GT_2885, [">="] = _GT_EQ_2889, ["abs"] = abs_2873, ["compare"] = compare_2545, ["div"] = div___2678, ["divMod"] = divMod_2720, ["fmt"] = fmt_2854, ["fromInt"] = fromInt_2345, ["max"] = max_2816, ["maxInt"] = maxInt_2353, ["min"] = min_2812, ["minInt"] = minInt_2351, ["mod"] = mod___2701, ["notb"] = notb_2824, ["precision"] = precision_2349, ["quot"] = quot_2747, ["quotRem"] = quotRem_2785, ["rem"] = rem_2766, ["sameSign"] = sameSign_2822, ["sign"] = sign_2820, ["toInt"] = toInt_2340, ["toString"] = toString_2839, ["~"] = _TILDE_2877, ["~>>"] = _TILDE_GT_GT_2595}} | |
eq_2902, IntInf_2903 = table_unpack(IntInf_2901, 1, 2) | |
end | |
local Rational_3038 | |
do | |
local gcdLoop_2926 | |
gcdLoop_2926 = function(a_2930) | |
local x_2932 = a_2930[1] | |
local y_2931 = a_2930[2] | |
local tmp216 = IntInf_2903["fromInt"](0) | |
local tmp217 = eq_2902({y_2931, tmp216}) | |
if tmp217 then | |
return x_2932 | |
else | |
local tmp218 = IntInf_2903["rem"]({x_2932, y_2931}) | |
return gcdLoop_2926({y_2931, tmp218}) | |
end | |
end | |
local makeRational_2933 = function(a_2934) | |
local x_2936 = a_2934[1] | |
local y_2935 = a_2934[2] | |
local tmp219 = IntInf_2903["fromInt"](0) | |
local tmp220 = eq_2902({y_2935, tmp219}) | |
if tmp220 then | |
_raise(_Div, "seki-bernoulli.sml:29:31") | |
else | |
local g_2937 | |
do | |
local x_9803 = a_2934[1] | |
local y_9804 = a_2934[2] | |
local tmp221 = IntInf_2903["abs"](x_9803) | |
local tmp222 = IntInf_2903["abs"](y_9804) | |
g_2937 = gcdLoop_2926({tmp221, tmp222}) | |
end | |
local tmp223 = IntInf_2903["fromInt"](0) | |
local tmp224 = IntInf_2903["<"]({y_2935, tmp223}) | |
if tmp224 then | |
local tmp225 = IntInf_2903["~"](x_2936) | |
local tmp226 = IntInf_2903["div"]({tmp225, g_2937}) | |
local tmp227 = IntInf_2903["~"](y_2935) | |
local tmp228 = IntInf_2903["div"]({tmp227, g_2937}) | |
return {["num"] = tmp226, ["den"] = tmp228} | |
else | |
local tmp229 = IntInf_2903["div"]({x_2936, g_2937}) | |
local tmp230 = IntInf_2903["div"]({y_2935, g_2937}) | |
return {["num"] = tmp229, ["den"] = tmp230} | |
end | |
end | |
end | |
local fromInt_2938 = function(a_2939) | |
local tmp231 = IntInf_2903["fromInt"](a_2939) | |
local tmp232 = IntInf_2903["fromInt"](1) | |
return {["num"] = tmp231, ["den"] = tmp232} | |
end | |
local fromIntInf_2941 = function(a_2942) | |
local tmp233 = IntInf_2903["fromInt"](1) | |
return {["num"] = a_2942, ["den"] = tmp233} | |
end | |
local numerator_2944 = function(tmp_3034) | |
return tmp_3034["num"] | |
end | |
local denominator_2946 = function(tmp_3035) | |
return tmp_3035["den"] | |
end | |
local add_2948 = function(a_2949) | |
local x_2951 = a_2949[1] | |
local y_2950 = a_2949[2] | |
local tmp_9805 = x_2951 | |
local tmp_9806 = y_2950 | |
local tmp234 = IntInf_2903["*"]({tmp_9805["num"], tmp_9806["den"]}) | |
local tmp_9807 = y_2950 | |
local tmp_9808 = x_2951 | |
local tmp235 = IntInf_2903["*"]({tmp_9807["num"], tmp_9808["den"]}) | |
local tmp236 = IntInf_2903["+"]({tmp234, tmp235}) | |
local tmp_9809 = x_2951 | |
local tmp_9810 = y_2950 | |
local tmp237 = IntInf_2903["*"]({tmp_9809["den"], tmp_9810["den"]}) | |
return makeRational_2933({tmp236, tmp237}) | |
end | |
local sub_2952 = function(a_2953) | |
local x_2955 = a_2953[1] | |
local y_2954 = a_2953[2] | |
local tmp_9811 = x_2955 | |
local tmp_9812 = y_2954 | |
local tmp238 = IntInf_2903["*"]({tmp_9811["num"], tmp_9812["den"]}) | |
local tmp_9813 = y_2954 | |
local tmp_9814 = x_2955 | |
local tmp239 = IntInf_2903["*"]({tmp_9813["num"], tmp_9814["den"]}) | |
local tmp240 = IntInf_2903["-"]({tmp238, tmp239}) | |
local tmp_9815 = x_2955 | |
local tmp_9816 = y_2954 | |
local tmp241 = IntInf_2903["*"]({tmp_9815["den"], tmp_9816["den"]}) | |
return makeRational_2933({tmp240, tmp241}) | |
end | |
local mul_2956 = function(a_2957) | |
local x_2959 = a_2957[1] | |
local y_2958 = a_2957[2] | |
local tmp_9817 = x_2959 | |
local tmp_9818 = y_2958 | |
local tmp242 = IntInf_2903["*"]({tmp_9817["num"], tmp_9818["num"]}) | |
local tmp_9819 = x_2959 | |
local tmp_9820 = y_2958 | |
local tmp243 = IntInf_2903["*"]({tmp_9819["den"], tmp_9820["den"]}) | |
return makeRational_2933({tmp242, tmp243}) | |
end | |
local divide_2960 = function(a_2961) | |
local x_2963 = a_2961[1] | |
local y_2962 = a_2961[2] | |
local tmp_9821 = x_2963 | |
local tmp_9822 = y_2962 | |
local tmp244 = IntInf_2903["*"]({tmp_9821["num"], tmp_9822["den"]}) | |
local tmp_9823 = x_2963 | |
local tmp_9824 = y_2962 | |
local tmp245 = IntInf_2903["*"]({tmp_9823["den"], tmp_9824["num"]}) | |
return makeRational_2933({tmp244, tmp245}) | |
end | |
local abs___2964 = function(a_2965) | |
local num_2967 = a_2965["num"] | |
local den_2966 = a_2965["den"] | |
local tmp246 = IntInf_2903["abs"](num_2967) | |
return {["num"] = tmp246, ["den"] = den_2966} | |
end | |
local negate_2968 = function(a_2969) | |
local num_2971 = a_2969["num"] | |
local den_2970 = a_2969["den"] | |
local tmp247 = IntInf_2903["~"](num_2971) | |
return {["num"] = tmp247, ["den"] = den_2970} | |
end | |
local compare_2972 = function(a_2973) | |
local x_2975 = a_2973[1] | |
local y_2974 = a_2973[2] | |
local tmp_9825 = x_2975 | |
local tmp_9826 = y_2974 | |
local tmp248 = IntInf_2903["*"]({tmp_9825["num"], tmp_9826["den"]}) | |
local tmp_9827 = y_2974 | |
local tmp_9828 = x_2975 | |
local tmp249 = IntInf_2903["*"]({tmp_9827["num"], tmp_9828["den"]}) | |
return IntInf_2903["compare"]({tmp248, tmp249}) | |
end | |
local _LT_2976 = function(a_2977) | |
local x_2979 = a_2977[1] | |
local y_2978 = a_2977[2] | |
local tmp_9829 = x_2979 | |
local tmp_9830 = y_2978 | |
local tmp250 = IntInf_2903["*"]({tmp_9829["num"], tmp_9830["den"]}) | |
local tmp_9831 = y_2978 | |
local tmp_9832 = x_2979 | |
local tmp251 = IntInf_2903["*"]({tmp_9831["num"], tmp_9832["den"]}) | |
return IntInf_2903["<"]({tmp250, tmp251}) | |
end | |
local _LT_EQ_2980 = function(a_2981) | |
local x_2983 = a_2981[1] | |
local y_2982 = a_2981[2] | |
local tmp_9833 = x_2983 | |
local tmp_9834 = y_2982 | |
local tmp252 = IntInf_2903["*"]({tmp_9833["num"], tmp_9834["den"]}) | |
local tmp_9835 = y_2982 | |
local tmp_9836 = x_2983 | |
local tmp253 = IntInf_2903["*"]({tmp_9835["num"], tmp_9836["den"]}) | |
return IntInf_2903["<="]({tmp252, tmp253}) | |
end | |
local _GT_2984 = function(a_2985) | |
local x_2987 = a_2985[1] | |
local y_2986 = a_2985[2] | |
local tmp_9837 = x_2987 | |
local tmp_9838 = y_2986 | |
local tmp254 = IntInf_2903["*"]({tmp_9837["num"], tmp_9838["den"]}) | |
local tmp_9839 = y_2986 | |
local tmp_9840 = x_2987 | |
local tmp255 = IntInf_2903["*"]({tmp_9839["num"], tmp_9840["den"]}) | |
return IntInf_2903[">"]({tmp254, tmp255}) | |
end | |
local _GT_EQ_2988 = function(a_2989) | |
local x_2991 = a_2989[1] | |
local y_2990 = a_2989[2] | |
local tmp_9841 = x_2991 | |
local tmp_9842 = y_2990 | |
local tmp256 = IntInf_2903["*"]({tmp_9841["num"], tmp_9842["den"]}) | |
local tmp_9843 = y_2990 | |
local tmp_9844 = x_2991 | |
local tmp257 = IntInf_2903["*"]({tmp_9843["num"], tmp_9844["den"]}) | |
return IntInf_2903[">="]({tmp256, tmp257}) | |
end | |
local toString_2992 = function(a_2993) | |
local tmp_10581, tmp_10582 | |
do | |
local tmp_10579, tmp_10580 | |
do | |
tmp_10580 = IntInf_2903["toString"](a_2993["num"]) | |
tmp_10579 = "/" | |
end | |
tmp_10582 = tmp_10580 .. tmp_10579 | |
tmp_10581 = IntInf_2903["toString"](a_2993["den"]) | |
end | |
return tmp_10582 .. tmp_10581 | |
end | |
local _PLUS_2995 = add_2948 | |
local _MINUS_2997 = sub_2952 | |
local _ASTER_2999 = mul_2956 | |
local _SLASH_3001 = divide_2960 | |
local abs_3003 = abs___2964 | |
local _TILDE_3005 = negate_2968 | |
local Rational_3036 = {_Record_EQUAL({["num"] = eq_2902, ["den"] = eq_2902}), {["*"] = _ASTER_2999, ["+"] = _PLUS_2995, ["-"] = _MINUS_2997, ["/"] = _SLASH_3001, ["<"] = _LT_2976, ["<="] = _LT_EQ_2980, [">"] = _GT_2984, [">="] = _GT_EQ_2988, ["abs"] = abs_3003, ["compare"] = compare_2972, ["denominator"] = denominator_2946, ["fromInt"] = fromInt_2938, ["fromIntInf"] = fromIntInf_2941, ["makeRational"] = makeRational_2933, ["numerator"] = numerator_2944, ["toString"] = toString_2992, ["~"] = _TILDE_3005}} | |
local eq_3037 | |
eq_3037, Rational_3038 = table_unpack(Rational_3036, 1, 2) | |
end | |
local computeBernoulliNumbers_3009 = function(a_3010) | |
local tmp258 = Rational_3038["fromInt"](0) | |
local bern_3012 = _Array_array({a_3010, tmp258}) | |
local tmp259 = Rational_3038["fromInt"](1) | |
update_1595({bern_3012, 0, tmp259}) | |
local loop_3013 | |
loop_3013 = function(a_3014) | |
local n_3016 = a_3014[1] | |
local comb_3015 = a_3014[2] | |
local x_9857 = a_3014[1] | |
if x_9857 >= a_3010 then | |
return nil | |
else | |
local tmp_10583, tmp_10584 | |
do | |
local a_9866 = comb_3015 | |
tmp_10584 = a_9866.n | |
tmp_10583 = 1 | |
end | |
local tmp260 = __Int_add(tmp_10584, tmp_10583) | |
local comb_3017 = _VectorOrArray_tabulate({tmp260, function(k_3018) | |
local tmp261 | |
if k_3018 == 0 then | |
tmp261 = true | |
else | |
local a_9872 = comb_3015 | |
tmp261 = k_3018 == a_9872.n | |
end | |
if tmp261 then | |
return IntInf_2903["fromInt"](1) | |
else | |
local tmp_10585 = 1 | |
local tmp262 = __Int_sub(k_3018, tmp_10585) | |
local tmp263 = sub_547({comb_3015, tmp262}) | |
local tmp264 = sub_547({comb_3015, k_3018}) | |
return IntInf_2903["+"]({tmp263, tmp264}) | |
end | |
end}) | |
local sum_3019 | |
do | |
local s_3020 | |
s_3020 = function(a_3021) | |
local k_3023 = a_3021[1] | |
local acc_3022 = a_3021[2] | |
local x_9881 = a_3021[1] | |
local y_9882 = a_3014[1] | |
if x_9881 >= y_9882 then | |
return acc_3022 | |
else | |
local tmp_10586 = 1 | |
local x_9885 = a_3021[1] | |
local tmp265 = __Int_add(x_9885, tmp_10586) | |
local tmp266 = sub_547({comb_3017, k_3023}) | |
local tmp267 = Rational_3038["fromIntInf"](tmp266) | |
local tmp268 = sub_1591({bern_3012, k_3023}) | |
local tmp269 = Rational_3038["*"]({tmp267, tmp268}) | |
local tmp270 = Rational_3038["+"]({acc_3022, tmp269}) | |
return s_3020({tmp265, tmp270}) | |
end | |
end | |
local tmp271 = Rational_3038["fromInt"](0) | |
sum_3019 = s_3020({0, tmp271}) | |
end | |
local tmp_10587 = 1 | |
local x_9889 = a_3014[1] | |
local tmp272 = __Int_add(x_9889, tmp_10587) | |
local tmp273 = Rational_3038["fromInt"](tmp272) | |
local tmp274 = Rational_3038["/"]({sum_3019, tmp273}) | |
local bern__n_3024 = Rational_3038["~"](tmp274) | |
update_1595({bern_3012, n_3016, bern__n_3024}) | |
local tmp_10588 = 1 | |
local x_9893 = a_3014[1] | |
local tmp275 = __Int_add(x_9893, tmp_10588) | |
return loop_3013({tmp275, comb_3017}) | |
end | |
end | |
local tmp276 = IntInf_2903["fromInt"](1) | |
local tmp277 = IntInf_2903["fromInt"](1) | |
loop_3013({1, { n = 2, tmp276, tmp277 }}) | |
return _VectorOrArray_tabulate({a_3010, function(i_3025) | |
return sub_1591({bern_3012, i_3025}) | |
end}) | |
end | |
local rationalToFrac_3028 = function(a_3029) | |
local num_3031 = Rational_3038["numerator"](a_3029) | |
local den_3032 = Rational_3038["denominator"](a_3029) | |
local tmp278 = IntInf_2903["fromInt"](1) | |
local tmp279 = eq_2902({den_3032, tmp278}) | |
if tmp279 then | |
local tmp280 = IntInf_2903["sign"](num_3031) | |
if tmp280 == -1 then | |
local tmp_10589, tmp_10590 | |
do | |
tmp_10590 = "-" | |
local tmp281 = IntInf_2903["~"](num_3031) | |
tmp_10589 = IntInf_2903["toString"](tmp281) | |
end | |
return tmp_10590 .. tmp_10589 | |
else | |
return IntInf_2903["toString"](num_3031) | |
end | |
else | |
local tmp282 = IntInf_2903["sign"](num_3031) | |
if tmp282 == -1 then | |
local tmp_10597, tmp_10598 | |
do | |
local tmp_10595, tmp_10596 | |
do | |
local tmp_10593, tmp_10594 | |
do | |
local tmp_10591, tmp_10592 | |
do | |
tmp_10592 = "-\\frac{" | |
local tmp283 = IntInf_2903["~"](num_3031) | |
tmp_10591 = IntInf_2903["toString"](tmp283) | |
end | |
tmp_10594 = tmp_10592 .. tmp_10591 | |
tmp_10593 = "}{" | |
end | |
tmp_10596 = tmp_10594 .. tmp_10593 | |
tmp_10595 = IntInf_2903["toString"](den_3032) | |
end | |
tmp_10598 = tmp_10596 .. tmp_10595 | |
tmp_10597 = "}" | |
end | |
return tmp_10598 .. tmp_10597 | |
else | |
local tmp_10605, tmp_10606 | |
do | |
local tmp_10603, tmp_10604 | |
do | |
local tmp_10601, tmp_10602 | |
do | |
local tmp_10599, tmp_10600 | |
do | |
tmp_10600 = "\\frac{" | |
tmp_10599 = IntInf_2903["toString"](num_3031) | |
end | |
tmp_10602 = tmp_10600 .. tmp_10599 | |
tmp_10601 = "}{" | |
end | |
tmp_10604 = tmp_10602 .. tmp_10601 | |
tmp_10603 = IntInf_2903["toString"](den_3032) | |
end | |
tmp_10606 = tmp_10604 .. tmp_10603 | |
tmp_10605 = "}" | |
end | |
return tmp_10606 .. tmp_10605 | |
end | |
end | |
end | |
return {computeBernoulliNumbers = computeBernoulliNumbers_3009, rationalToFrac = rationalToFrac_3028} |
This file contains 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
structure Rational :> sig | |
eqtype rational | |
val fromInt : Int.int -> rational | |
val fromIntInf : IntInf.int -> rational | |
val makeRational : IntInf.int * IntInf.int -> rational | |
val numerator : rational -> IntInf.int | |
val denominator : rational -> IntInf.int | |
val + : rational * rational -> rational | |
val - : rational * rational -> rational | |
val * : rational * rational -> rational | |
val / : rational * rational -> rational | |
val abs : rational -> rational | |
val ~ : rational -> rational | |
val compare : rational * rational -> order | |
val < : rational * rational -> bool | |
val <= : rational * rational -> bool | |
val > : rational * rational -> bool | |
val >= : rational * rational -> bool | |
val toString : rational -> string | |
end = struct | |
(* invariant: den is strictly positive, gcd (num, den) = 1 *) | |
type rational = { num : IntInf.int, den : IntInf.int } | |
fun gcd (x, y) = gcdLoop (IntInf.abs x, IntInf.abs y) | |
and gcdLoop (x, y) = if y = IntInf.fromInt 0 then | |
x | |
else | |
gcdLoop (y, IntInf.rem (x, y)) | |
fun makeRational (x, y) = if y = IntInf.fromInt 0 then | |
raise Div | |
else | |
let val g = gcd (x, y) | |
in if y < IntInf.fromInt 0 then | |
{ num = (~ x) div g, den = (~ y) div g } | |
else | |
{ num = x div g, den = y div g } | |
end | |
fun fromInt x = { num = IntInf.fromInt x, den = IntInf.fromInt 1 } | |
fun fromIntInf (x : IntInf.int) = { num = x, den = IntInf.fromInt 1 } | |
val numerator = #num : rational -> IntInf.int | |
val denominator = #den : rational -> IntInf.int | |
fun add (x, y) = makeRational (numerator x * denominator y + numerator y * denominator x, denominator x * denominator y) | |
fun sub (x, y) = makeRational (numerator x * denominator y - numerator y * denominator x, denominator x * denominator y) | |
fun mul (x, y) = makeRational (numerator x * numerator y, denominator x * denominator y) | |
fun divide (x : rational, y : rational) = makeRational (numerator x * denominator y, denominator x * numerator y) | |
fun abs_ { num, den } = { num = IntInf.abs num, den = den : IntInf.int } | |
fun negate { num, den } = { num = IntInf.~ num, den = den : IntInf.int } | |
fun compare (x : rational, y : rational) = IntInf.compare (numerator x * denominator y, numerator y * denominator x) | |
fun x < y = IntInf.< (numerator x * denominator y, numerator y * denominator x) | |
fun x <= y = IntInf.<= (numerator x * denominator y, numerator y * denominator x) | |
fun x > y = IntInf.> (numerator x * denominator y, numerator y * denominator x) | |
fun x >= y = IntInf.>= (numerator x * denominator y, numerator y * denominator x) | |
fun toString x = IntInf.toString (numerator x) ^ "/" ^ IntInf.toString (denominator x) | |
val op + = add | |
val op - = sub | |
val op * = mul | |
val op / = divide | |
val abs = abs_ | |
val ~ = negate | |
end | |
fun computeBernoulliNumbers (limit : int) : Rational.rational vector | |
= let val bern = Array.array (limit, Rational.fromInt 0) | |
val () = Array.update (bern, 0, Rational.fromInt 1) | |
val () = let fun loop (n, comb) = if n >= limit then | |
() | |
else | |
let val comb = Vector.tabulate (Vector.length comb + 1, fn k => if k = 0 orelse k = Vector.length comb then | |
IntInf.fromInt 1 | |
else | |
Vector.sub (comb, k - 1) + Vector.sub (comb, k) | |
) | |
val sum = let fun s (k, acc) = if k >= n then | |
acc | |
else | |
s (k + 1, Rational.+ (acc, Rational.* (Rational.fromIntInf (Vector.sub (comb, k)), Array.sub (bern, k)))) | |
in s (0, Rational.fromInt 0) | |
end | |
val bern_n = Rational.~ (Rational./ (sum, Rational.fromInt (n + 1))) | |
in Array.update (bern, n, bern_n) | |
; loop (n + 1, comb) | |
end | |
in loop (1, vector [IntInf.fromInt 1, IntInf.fromInt 1]) | |
end | |
in Vector.tabulate (limit, fn i => Array.sub (bern, i)) | |
end | |
structure export = struct | |
val computeBernoulliNumbers = computeBernoulliNumbers | |
fun rationalToFrac (x : Rational.rational) : string = let val num = Rational.numerator x | |
val den = Rational.denominator x | |
in if den = IntInf.fromInt 1 then | |
if IntInf.sign num = ~1 then | |
"-" ^ IntInf.toString (~ num) | |
else | |
IntInf.toString num | |
else | |
if IntInf.sign num = ~1 then | |
"-\\frac{" ^ IntInf.toString (~ num) ^ "}{" ^ IntInf.toString den ^ "}" | |
else | |
"\\frac{" ^ IntInf.toString num ^ "}{" ^ IntInf.toString den ^ "}" | |
end | |
end |
This file contains 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
\documentclass{article} | |
\usepackage{amsmath} | |
\usepackage{luacode} | |
\begin{document} | |
\allowdisplaybreaks | |
\begin{luacode*} | |
local M = require "seki-bernoulli" | |
local N = 100 | |
local bern = M.computeBernoulliNumbers(N) | |
tex.print("\\begin{align*}") | |
for i = 0, N-1 do | |
local frac = M.rationalToFrac(bern[i+1]) | |
local lineterm | |
if i == N-1 then | |
lineterm = "" | |
else | |
lineterm = "\\\\" | |
end | |
tex.print(string.format("B_{%i}&={%s}%s",i,frac,lineterm)) | |
end | |
tex.print("\\end{align*}") | |
\end{luacode*} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment