KoboldAI-Client/userscripts/examples/haxe_transcend.min.lua

47 lines
276 KiB
Lua
Raw Normal View History

-- Haxe transcendental test
2022-01-01 07:34:32 +01:00
-- This is a script written in Haxe that prints the natural logarithm of the
-- golden ratio in base 10 to arbitrarily many digits.
-- This file is part of KoboldAI.
--
-- KoboldAI is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
-- License for littleBigInt:
-- MIT License
--
-- Copyright (c) 2020 Sylvio Sell
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
2022-01-01 07:34:32 +01:00
local a={__id__=true,hx__closures=true,super=true,prototype=true,__fields__=true,__ifields__=true,__class__=true,__properties__=true,__fields__=true,__name__=true}_hx_array_mt={__newindex=function(b,c,d)local e=b.length;b.length=c>=e and c+1 or e;rawset(b,c,d)end}function _hx_is_array(f)return type(f)=="table"and f.__enum__==nil and getmetatable(f)==_hx_array_mt end;function _hx_tab_array(g,h)g.length=h;return setmetatable(g,_hx_array_mt)end;function _hx_print_class(i,j)local k=true;local l=''for c,d in pairs(i)do if a[c]==nil then if k then k=false else l=l..', 'end;if a[c]==nil then l=l..c..':'.._hx_tostring(d,j+1)end end end;return'{ '..l..' }'end;function _hx_print_enum(f,j)if f.length==2 then return f[0]else local m=f[0].."("for n=2,f.length-1 do if n~=2 then m=m..",".._hx_tostring(f[n],j+1)else m=m.._hx_tostring(f[n],j+1)end end;return m..")"end end;function _hx_tostring(i,j)if j==nil then j=0 elseif j>5 then return"<...>"end;local o=_G.type(i)if o=="string"then return i elseif o=="nil"then return"null"elseif o=="number"then if i==_G.math.POSITIVE_INFINITY then return"Infinity"elseif i==_G.math.NEGATIVE_INFINITY then return"-Infinity"elseif i==0 then return"0"elseif i~=i then return"NaN"else return _G.tostring(i)end elseif o=="boolean"then return _G.tostring(i)elseif o=="userdata"then local p=_G.getmetatable(i)if p~=nil and p.__tostring~=nil then return _G.tostring(i)else return"<userdata>"end elseif o=="function"then return"<function>"elseif o=="thread"then return"<thread>"elseif o=="table"then if i.__enum__~=nil then return _hx_print_enum(i,j)elseif i.toString~=nil and not _hx_is_array(i)then return i:toString()elseif _hx_is_array(i)then if i.length>5 then return"[...]"else local m=""for n=0,i.length-1 do if n==0 then m=m.._hx_tostring(i[n],j+1)else m=m..",".._hx_tostring(i[n],j+1)end end;return"["..m.."]"end elseif i.__class__~=nil then return _hx_print_class(i,j)else local q={}local r=i;if i.__fields__~=nil then r=i.__fields__ end;for c,d in pairs(r)do if a[c]==nil then _G.table.insert(q,_hx_tostring(c,j+1)..' : '.._hx_tostring(i[c],j+1))end end;return"{ "..table.concat(q,", ").." }"end else _G.error("Unknown Lua type",0)return""end end;function _hx_error(i)if i.value then _G.print("runtime error:\n ".._hx_tostring(i.value))else _G.print("runtime error:\n "..tostring(i))end;if _G.debug and _G.debug.traceback then _G.print(debug.traceback())end end;local function s(b,c,d)b.__fields__[c]=true;rawset(b,c,d)end;local t={__newindex=s,__tostring=_hx_tostring}local function u(...)local v={}local w={__fields__=v}local x=select('#',...)local g={...}local y=1;while y<x do local d=g[y]v[d]=true;w[d]=g[y+1]y=y+2 end;return setmetatable(w,t)end;local function z()return setmetatable({__fields__={}},t)end;local function A(i)return setmetatable(i,t)end;local function B(C)return setmetatable({__fields__={}},{__newindex=s,__index=C,__tostring=_hx_tostring})end;function _hx_field_arr(i)res={}idx=0;if i.__fields__~=nil then i=i.__fields__ end;for c,d in pairs(i)do if a[c]==nil then res[idx]=c;idx=idx+1 end end;return _hx_tab_array(res,idx)end;local D={}local E=z()local F=z()local G=z()local H=z()local I=z()local J=z()local _hx_exports=_hx_exports or{}local K=z()___BigInt_BigInt_Impl_=z()__lua_lib_lrexlib_Rex={flags=function()return{CASELESS=1,DOTALL=1,MULTILINE=1,UCP=1,UTF8=1}end,gsub=function()return""end,new=function()return{}end}__lua_lib_luautf8_Utf8={byte=_G.string.byte,find=_G.string.find,gmatch=_G.string.gmatch,gsub=_G.string.gsub,lower=_G.string.lower,match=_G.string.match,reverse=_G.string.reverse,sub=_G.string.sub,upper=_G.string.upper}for c,d in pairs(_G.utf8)do __lua_lib_luautf8_Utf8[c]=d end;local L=z()local M=z()local N=z()local O=z()local P=z()local Q=z()local R=z()__haxe_Exception=z()__haxe_Log=z()__haxe_NativeStackTrace=z()__haxe_ValueException=z()__haxe_exceptions_PosException=z()__haxe_io_Bytes=z()__haxe_iterators_ArrayIterator=z()__haxe_iterators_ArrayKeyValueIterator=z()__lua_Boot=z()__lua_UserData=z()__lua_Thread=z()local S,T,U,V,W,X,Y,Z,_,a0,a1;local a2={}local a3={}K.new=function()local self=B(K.prototype)