mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2024-12-12 00:35:41 +01:00
7 lines
26 KiB
Lua
7 lines
26 KiB
Lua
|
-- Moses @6fe8d76d50a22d85fe064aaa80390b72381befed | /moses.lua | https://github.com/Yonaba/Moses | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
|
||
|
-- Copyright (c) 2012-2018 Roland Yonaba
|
||
|
-- 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.
|
||
|
local a='2.1.0'local next,type,pcall=next,type,pcall;local setmetatable,getmetatable=setmetatable,getmetatable;local b,c=table.insert,table.sort;local d,e=table.remove,table.concat;local f,g,h=math.randomseed,math.random,math.huge;local i,j,k,l=math.floor,math.max,math.min,math.ceil;local m=coroutine.wrap;local n=coroutine.yield;local rawget=rawget;local unpack=table.unpack or unpack;local pairs,ipairs=pairs,ipairs;local error=error;local o=os and os.clock or nil;local p={}local function q(r,s)return r>s end;local function t(r,s)return r<s end;local function u(v)local w=0;for x,y in pairs(v)do w=w+1 end;return w end;local function z(A,B,C,...)C=C or p.identity;local D;for x,y in pairs(A)do if not D then D=C(y,...)else local E=C(y,...)D=B(D,E)and D or E end end;return D end;local function F(v,G,H,I)for w=0,#v,G do local J=p.slice(v,w+1,w+G)if#J>0 then while#J<G and I do J[#J+1]=I end;H(J)end end end;local function K(v,G,H,I)for w=0,#v,G-1 do local J=p.slice(v,w+1,w+G)if#J>0 and w+1<#v then while#J<G and I do J[#J+1]=I end;H(J)end end end;local function L(v,G,H,I)for w=0,#v,1 do local J=p.slice(v,w+1,w+G)if#J>0 and w+G<=#v then while#J<G and I do J[#J+1]=I end;H(J)end end end;local function M(v,G,H)if G==0 then H(v)end;for w=1,G do v[G],v[w]=v[w],v[G]M(v,G-1,H)v[G],v[w]=v[w],v[G]end end;local function N(r)return r>=0 and 1 or-1 end;local O=-1;p.operator={}p.operator.add=function(r,s)return r+s end;p.operator.sub=function(r,s)return r-s end;p.operator.mul=function(r,s)return r*s end;p.operator.div=function(r,s)return r/s end;p.operator.mod=function(r,s)return r%s end;p.operator.exp=function(r,s)return r^s end;p.operator.pow=p.operator.exp;p.operator.unm=function(r)return-r end;p.operator.neg=p.operator.unm;p.operator.floordiv=function(r,s)return i(r/s)end;p.operator.intdiv=function(r,s)return r>=0 and i(r/s)or l(r/s)end;p.operator.eq=function(r,s)return r==s end;p.operator.neq=function(r,s)return r~=s end;p.operator.lt=function(r,s)return r<s end;p.operator.gt=function(r,s)return r>s end;p.operator.le=function(r,s)return r<=s end;p.operator.ge=function(r,s)return r>=s end;p.operator.land=function(r,s)return r and s end;p.operator.lor=function(r,s)return r or s end;p.operator.lnot=function(r)return not r end;p.operator.concat=function(r,s)return r..s end;p.operator.length=function(r)return#r end;p.operator.len=p.operator.length;function p.clear(v)for x in pairs(v)do v[x]=nil end;return v end;function p.each(v,H)for P,Q in pairs(v)do H(Q,P)end end;function p.eachi(v,H)local R=p.sort(p.select(p.keys(v),p.isInteger))for x,S in ipairs(R)do H(v[S],S)end end;function p.at(v,...)local T={}for w,S in ipairs({...})do T[#T+1]=v[S]end;return T end;function p.adjust(v,S,H)if v[S]==nil then error("key not existing in table")end;local U=p.clone(v)U[S]=type(H)=='function'and H(U[S])or H;return U end;function p.count(v,E)if E==nil then return p.size(v)end;local u=0;for x,y in pairs(v)do if p.isEqual(y,E)then u=u+1 end end;return u end;function p.countf(v,H)local u=0;for x,y in pairs(v)do if H(y,x)then u=u+1 end end;return u end;function p.allEqual(v,B)local x,V=next(v)for x,y in pairs(v)do if B then if not B(V,y)then return false end else if not p.isEqual(V,y)then return false end end end;return true end;function p.cycle(v,G)G=G or 1;if G<=0 then return p.noop end;local x,W;local w=0;while true do return function()x=x and next(v,x)or next(v)W=not W and x or W;if G then w=x==W and w+1 or w;if w>G then return end end;return v[x],x end end end;function p.map(v,H)local U={}for P,Q in pairs(v)do local x,X,y=P,H(Q,P)U[y and X or x]=y or X end;return U end;function p.mapi(v,H)local U={}for P,Q in ipairs(v)do local x,X,y=P,H(Q,P)U[y and X or x]=y or X end;return U end;function p.reduce(v,H,Y)for x,Q in pairs(v)do if Y==nil then Y=Q else Y=H(Y,Q)end end;return Y end;function p.best(v,H)local Z,Y=next(v)for x,Q in pairs(v)do if Y==nil then Y=Q else Y=H(Y,Q)and Y or Q end end;return Y end;function p.reduceBy(v,H,_,Y)return p.reduce(p.select(v,_),H,Y)end;function p.reduceRight(v,H,Y)return p.reduce(p.reverse(v),H,Y)end;function p.mapReduce(v,H,Y)local
|