3SQFGCFL4JHMT6XP3EJNESBXVWRIOVOJVO4OOVSJMHFOZQ6QKJTQC local parent = table:parent()if parent thenif rawget(parent, "_prototype") thenreturn (rawget(parent._prototype, key) or parent[key])
local parent = table:parent()if parent thenif rawget(parent, "_prototype") thenreturn (rawget(parent._prototype, key) or parent[key])elsereturn parent[key]end
local compare = function (lhs, rhs)if type(lhs) == "table" and type(rhs) == "table" thenif lhs._less_equal_greater ~= nil thenreturn lhs:_less_equal_greater(rhs) == -1
local compare = function(lhs, rhs)if type(lhs) == "table" and type(rhs) == "table" thenif lhs._less_equal_greater ~= nil thenreturn lhs:_less_equal_greater(rhs) == -1endelseif type(lhs) == "number" and type(rhs) == "number" thenlocal lhs = number:new(lhs)return lhs:_less_equal_greater(rhs) == -1
function _lifted_call (block, arg_table)local _call_thing = {}_call_thing.block = block_call_thing.arg_table = arg_table_call_thing.__call_thing = truesetmetatable(_call_thing, _call_table)
function _lifted_call(block, arg_table)local _call_thing = {}_call_thing.block = block_call_thing.arg_table = arg_table_call_thing.__call_thing = truesetmetatable(_call_thing, _call_table)
function is_callable (thing)return type(thing) == "function" or (type(thing) == "table" and rawget(thing, "__call_thing"))
function is_callable(thing)return type(thing) == "function" or (type(thing) == "table" and rawget(thing, "__call_thing"))
local escape_ops = { ["!"] = "_bang",["*"] = "_star",["-"] = "_minus",["+"] = "_plus",["|"] = "_or",["&"] = "_and",["@"] = "_at",["~"] = "_tilde",["^"] = "_up",["/"] = "_forward",["\\"] = "_back",["?"] = "_question",["<"] = "_less",[">"] = "_greater",["="] = "_equal",["%"] = "_percent",["_"] = "_under",["$"] = "_dollar"
local escape_ops = {["!"] = "_bang",["*"] = "_star",["-"] = "_minus",["+"] = "_plus",["|"] = "_or",["&"] = "_and",["@"] = "_at",["~"] = "_tilde",["^"] = "_up",["/"] = "_forward",["\\"] = "_back",["?"] = "_question",["<"] = "_less",[">"] = "_greater",["="] = "_equal",["%"] = "_percent",["_"] = "_under",["$"] = "_dollar"
local unescape_ops = { ["bang"] = "!",["star"] = "*",["minus"] = "-",["plus"] = "+",["or"] = "|" ,["and"] = "&",["at"] = "@",["tilde"] = "~",["up"] = "^",["forward"] = "/",["back"] = "\\",["question"] = "?",["less"] = "<",["greater"] = ">",["notequal"] = "!=",["equal"] = "=",["percent"] = "%",["under"] = "_",["dollar"] = "$"
local unescape_ops = {["bang"] = "!",["star"] = "*",["minus"] = "-",["plus"] = "+",["or"] = "|",["and"] = "&",["at"] = "@",["tilde"] = "~",["up"] = "^",["forward"] = "/",["back"] = "\\",["question"] = "?",["less"] = "<",["greater"] = ">",["notequal"] = "!=",["equal"] = "=",["percent"] = "%",["under"] = "_",["dollar"] = "$"
local esc_keywords = orex.new("\\b(and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\\b")local underscore = function (word)return "__" .. word
local esc_keywords = orex.new("\\b(and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\\b")local underscore = function(word)return "__" .. word
return id_nameelselocal name = orex.gsub(id_name, esc_symbols, escape_ops)name = orex.gsub(name, esc_keywords, underscore)
return id_nameelselocal name = orex.gsub(id_name, esc_symbols, escape_ops)name = orex.gsub(name, esc_keywords, underscore)
local unesc_symbols = orex.new("_(bang|star|minus|plus|or|and|at|tilde|up|forward|back|question|less|greater|equal|percent|under|dollar)")local unesc_keywords = orex.new("__(and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)")local ununderscore = function (word)string.sub(word, 1)
local unesc_symbols = orex.new("_(bang|star|minus|plus|or|and|at|tilde|up|forward|back|question|less|greater|equal|percent|under|dollar)")local unesc_keywords = orex.new("__(and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)")local ununderscore = function(word)string.sub(word, 1)
local unescape_identifier = function (name)name = orex.gsub(name, unesc_keywords, ununderscore)name = orex.gsub(name, unesc_symbols, unescape_ops)
local unescape_identifier = function(name)name = orex.gsub(name, unesc_keywords, ununderscore)name = orex.gsub(name, unesc_symbols, unescape_ops)
if is_callable(methods_or_block) thenself._prototype:with_underthis(methods_or_block)elselocal proto = self._prototype
if is_callable(methods_or_block) thenself._prototype:with_underthis(methods_or_block)elselocal proto = self._prototype
methods_or_block:each(function(self, name, meth)if is_callable(meth) thenproto:add_undermethod(name, meth)elseproto:add_undermethod(name, function(self)return meth
methods_or_block:each(function(self, name, meth)if is_callable(meth) thenproto:add_undermethod(name, meth)elseproto:add_undermethod(name, function(self)return methend)end
function object:to_unders ()local meths = self:local_undermethods()return base_string:new("object" .. tostring(meths:sort_bang()))
function object:to_unders()local meths = self:local_undermethods()return base_string:new("object" .. tostring(meths:sort_bang()))
function object:methods ()local m = {}local i = 1if self:parent() ~= object.__null thenm = self:parent():methods()._lua_arrayi = #m + 1elsem = {}end
function object:methods()local m = {}local i = 1if self:parent() ~= object.__null thenm = self:parent():methods()._lua_arrayi = #m + 1elsem = {}end
for k,v in pairs(self) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1
for k, v in pairs(self) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1end
for k,v in pairs(self:parent()._prototype) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1
for k, v in pairs(self:parent()._prototype) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1end
local i = 1for k,v in pairs(self) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1
local i = 1for k, v in pairs(self) dok = unescape_identifier(k)if k:find("_", 1, true) ~= 1 thenm[i] = base_string:new(k)i = i + 1end
if select('#', ...) > 0 thenlocal input = {...}for k,v in pairs(input) doinput[k] = tostring(v)endio.write(unpack(input))
if select('#', ...) > 0 thenlocal input = { ... }for k, v in pairs(input) doinput[k] = tostring(v)endio.write(unpack(input))end
function object:function_question (obj)if obj == nil thenreturn falseelseif is_callable(obj) thenreturn object.__trueelsereturn object.__falseend
function object:function_question(obj)if obj == nil thenreturn falseelseif is_callable(obj) thenreturn object.__trueelsereturn object.__falseend
function object:object_question (obj)if obj == nil thenreturn self:object_question(self)elseif type(obj) == "table" thenreturn object.__trueelsereturn object.__falseend
function object:object_question(obj)if obj == nil thenreturn self:object_question(self)elseif type(obj) == "table" thenreturn object.__trueelsereturn object.__falseend
local len = select("#", ...)if len == 1 thenlocal first = select(1, ...)if first == 0 thenreturn 0elseif type(first) == "number" and first < 1 thenerror(exception:argument_error("random", "number > 0", tostring(first)))
local len = select("#", ...)if len == 1 thenlocal first = select(1, ...)if first == 0 thenreturn 0elseif type(first) == "number" and first < 1 thenerror(exception:argument_error("random", "number > 0", tostring(first)))endelseif len > 2 thenerror(exception:argument_error("random", "at most 2", len))
function object:ask (prompt)if prompt == nil thenreturn self:g()elseif type(prompt) ~= "table" or prompt._lua_string == nil thenerror(exception:argument_error("ask", "string", tostring(prompt)))end
function object:ask(prompt)if prompt == nil thenreturn self:g()elseif type(prompt) ~= "table" or prompt._lua_string == nil thenerror(exception:argument_error("ask", "string", tostring(prompt)))end
function object:_equal_equal (rhs)if self == rhs thenreturn object.__trueelseif self["_less_equal_greater"] thenif self:_less_equal_greater(rhs) == 0 thenreturn object.__true
function object:_equal_equal(rhs)if self == rhs thenreturn object.__trueelseif self["_less_equal_greater"] thenif self:_less_equal_greater(rhs) == 0 thenreturn object.__trueelsereturn object.__falseend
if len == 3 thenreturn self:_3_true_question(...)elseif len == 2 thenreturn self:_2_true_question(...)elseif len == 1 thenreturn self:_1_true_question(...)elseif len == 0 thenreturn self:_0_true_question()elseerror("Too many arguments for true?")end
if len == 3 thenreturn self:_3_true_question(...)elseif len == 2 thenreturn self:_2_true_question(...)elseif len == 1 thenreturn self:_1_true_question(...)elseif len == 0 thenreturn self:_0_true_question()elseerror("Too many arguments for true?")end
function object:_1_true_question (obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_1_true_question(obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_2_true_question (condition, true_branch)if is_callable(condition) thencondition = condition(self)end
function object:_2_true_question(condition, true_branch)if is_callable(condition) thencondition = condition(self)end
function object:_3_true_question (condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)endif is_true(condition) thenif is_callable(true_branch) thenreturn true_branch(self, condition)elsereturn true_branch
function object:_3_true_question(condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)
if len == 3 thenreturn self:_3_false_question(...)elseif len == 2 thenreturn self:_2_false_question(...)elseif len == 1 thenreturn self:_1_false_question(...)elseif len == 0 thenreturn self:_0_false_question()elseerror("Too many arguments for false?")end
if len == 3 thenreturn self:_3_false_question(...)elseif len == 2 thenreturn self:_2_false_question(...)elseif len == 1 thenreturn self:_1_false_question(...)elseif len == 0 thenreturn self:_0_false_question()elseerror("Too many arguments for false?")end
function object:_1_false_question (obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_1_false_question(obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_2_false_question (condition, true_branch)if is_callable(condition) thencondition = condition(self)end
function object:_2_false_question(condition, true_branch)if is_callable(condition) thencondition = condition(self)end
function object:_3_false_question (condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)end
function object:_3_false_question(condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)end
if len == 3 thenreturn self:_3_null_question(...)elseif len == 2 thenreturn self:_2_null_question(...)elseif len == 1 thenreturn self:_1_null_question(...)elseif len == 0 thenreturn self:_0_null_question()elseerror("Too many arguments for true?")end
if len == 3 thenreturn self:_3_null_question(...)elseif len == 2 thenreturn self:_2_null_question(...)elseif len == 1 thenreturn self:_1_null_question(...)elseif len == 0 thenreturn self:_0_null_question()elseerror("Too many arguments for true?")end
function object:_1_null_question (obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_1_null_question(obj)local conditionif is_callable(obj) thencondition = obj(self)elsecondition = objend
function object:_2_null_question (condition, true_branch)if is_callable(condition) thencondition = condition(self)end
function object:_2_null_question(condition, true_branch)if is_callable(condition) thencondition = condition(self)end
if condition == object.__null thenif is_callable(true_branch) thenreturn true_branch(self, condition)
if condition == object.__null thenif is_callable(true_branch) thenreturn true_branch(self, condition)elsereturn true_branchend
function object:_3_null_question (condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)end
function object:_3_null_question(condition, true_branch, false_branch)if is_callable(condition) thencondition = condition(self)end
if condition == object.__null thenif is_callable(true_branch) thenreturn true_branch(self, condition)elsereturn true_branchendelseif is_callable(false_branch) thenreturn false_branch(self, condition)
if condition == object.__null thenif is_callable(true_branch) thenreturn true_branch(self, condition)elsereturn true_branchend
function object:_while (...)local args = {...}local arglen = #argsif arglen == 1 thenwhile is_true(args[1](self)) do--nothingendelseif arglen == 2 thenif is_callable(args[1]) thenwhile is_true(args[1](self)) doargs[2](self)end
function object:_while(...)local args = { ... }local arglen = #argsif arglen == 1 thenwhile is_true(args[1](self)) do--nothingendelseif arglen == 2 thenif is_callable(args[1]) thenwhile is_true(args[1](self)) doargs[2](self)endelsewhile is_true(args[1]) doargs[2](self)endendelseif arglen == 0 thenerror(exception:argument_error("while", "at least 1", "none"))
function object:_until (...)local args = {...}local arglen = #argsif arglen == 1 thenwhile not is_true(args[1](self)) do--nothingendelseif arglen == 2 thenif is_callable(args[1]) thenwhile not is_true(args[1](self)) doargs[2](self)end
function object:_until(...)local args = { ... }local arglen = #argsif arglen == 1 thenwhile not is_true(args[1](self)) do--nothingendelseif arglen == 2 thenif is_callable(args[1]) thenwhile not is_true(args[1](self)) doargs[2](self)endelsewhile not is_true(args[1]) doargs[2](self)endend
function object:_or_or (rhs)if is_true(self) thenreturn selfelseif is_callable(rhs) thenreturn rhs(self)elsereturn rhsend
function object:_or_or(rhs)if is_true(self) thenreturn selfelseif is_callable(rhs) thenreturn rhs(self)elsereturn rhsend
function object:get_undermethod (name)name = to_identifier(name)if self[name] == nil thenreturn object.__nullelsereturn self[name]end
function object:get_undermethod(name)name = to_identifier(name)if self[name] == nil thenreturn object.__nullelsereturn self[name]end
function object:has_undermethod_question (name)name = to_identifier(name)if self[name] ~= nil thenreturn object.__trueelsereturn object.__falseend
function object:has_undermethod_question(name)name = to_identifier(name)if self[name] ~= nil thenreturn object.__trueelsereturn object.__falseend
function object:call_undermethod (name, ...)name = to_identifier(name)if self[name] == nil thenerror("No such method to call: " .. name .. " on " .. tostring(self))elsereturn self[name](self, ...)end
function object:call_undermethod(name, ...)name = to_identifier(name)if self[name] == nil thenerror("No such method to call: " .. name .. " on " .. tostring(self))elsereturn self[name](self, ...)end
function object:apply (meth, args)if type(args) ~= "table" or args._lua_array == nil thenreturn meth(self, args)elsereturn meth(self, unpack(args._lua_array))end
function object:apply(meth, args)if type(args) ~= "table" or args._lua_array == nil thenreturn meth(self, args)elsereturn meth(self, unpack(args._lua_array))end
function object:with_underthis (block, ...)local args = {...}if #args == 0 thenreturn block(self)elsereturn block(self, unpack(args))end
function object:with_underthis(block, ...)local args = { ... }if #args == 0 thenreturn block(self)elsereturn block(self, unpack(args))end
function object:protect (block, options)if options == nil thenlocal status, result = pcall(block, self)if status thenreturn resultelsereturn object.__nullendelseif type(options) == "table" and options._lua_hash ~= nil thenlocal ensure = options:get(base_string:new("ensure"))local rescue = options:get(base_string:new("rescue"))local filter = options:get(base_string:new("from"))
function object:protect(block, options)if options == nil thenlocal status, result = pcall(block, self)if status thenreturn resultelsereturn object.__nullendelseif type(options) == "table" and options._lua_hash ~= nil thenlocal ensure = options:get(base_string:new("ensure"))local rescue = options:get(base_string:new("rescue"))local filter = options:get(base_string:new("from"))
if (rescue and not is_callable(rescue)) or (ensure and not is_callable(ensure)) thenerror(exception:argument_error("protect", "function", tostring(options)))end
if (rescue and not is_callable(rescue)) or (ensure and not is_callable(ensure)) thenerror(exception:argument_error("protect", "function", tostring(options)))end
if rescue thenhandler = function(err)if type(err) ~= "table" or err._lua_string thenerr = exception:new(tostring(err))end
if rescue thenhandler = function(err)if type(err) ~= "table" or err._lua_string thenerr = exception:new(tostring(err))end
if status == false and type(result) == "table" and result.typeand filter and filter._lua_string ~= result.type()._lua_string then
if status == false and type(result) == "table" and result.typeand filter and filter._lua_string ~= result.type()._lua_string thenerror(result)end
function object:__type (obj)if obj == nil thenreturn object:__type(self)elselocal t = type(obj)if t == "table" thenif obj._lua_array thenreturn "array"elseif obj._lua_string thenreturn "string"elseif obj._lua_regex thenreturn "regex"elseif obj._lua_hash thenreturn "hash"elseif obj._lua_number thenreturn "number"elsereturn "object"end
function object:__type(obj)if obj == nil thenreturn object:__type(self)
return t
local t = type(obj)if t == "table" thenif obj._lua_array thenreturn "array"elseif obj._lua_string thenreturn "string"elseif obj._lua_regex thenreturn "regex"elseif obj._lua_hash thenreturn "hash"elseif obj._lua_number thenreturn "number"elsereturn "object"endelsereturn tend
function object:include (file, name, env_level)--env_level is used to call to include from another function--it sets what environment the file is imported to
function object:include(file, name, env_level)--env_level is used to call to include from another function--it sets what environment the file is imported to
if status thenif name thenfor k,v in pairs(_exports) doif k == name thenenv[to_identifier(k)] = v
if status thenif name thenfor k, v in pairs(_exports) doif k == name thenenv[to_identifier(k)] = vendendelsefor k, v in pairs(_exports) doenv[to_identifier(k)] = vend
function object:program_underargs ()if self._program_args == nil thenlocal arg_array = {}local len = #arglocal i = 1local j = 0
function object:program_underargs()if self._program_args == nil thenlocal arg_array = {}local len = #arglocal i = 1local j = 0
function object:when (...)local args = {...}local len = #argsif len % 2 == 1 thenerror(exception:argument_error("when", "an even number of", len))end
function object:when(...)local args = { ... }local len = #argsif len % 2 == 1 thenerror(exception:argument_error("when", "an even number of", len))end
true_question = object.true_question;false_question = object.false_question;null_question = object.null_question;when = object.when;
true_question = object.true_question,false_question = object.false_question,null_question = object.null_question,when = object.when,
function comparable:_greater (rhs)local cmp = self:_less_equal_greater(rhs)if cmp == 1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_greater(rhs)local cmp = self:_less_equal_greater(rhs)if cmp == 1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_less (rhs)local cmp = self:_less_equal_greater(rhs)if cmp == -1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_less(rhs)local cmp = self:_less_equal_greater(rhs)if cmp == -1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_less_equal (rhs)local cmp = self:_less_equal_greater(rhs)if cmp < 1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_less_equal(rhs)local cmp = self:_less_equal_greater(rhs)if cmp < 1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_greater_equal (rhs)local cmp = self:_less_equal_greater(rhs)if cmp > -1 thenreturn object.__trueelsereturn object.__falseend
function comparable:_greater_equal(rhs)local cmp = self:_less_equal_greater(rhs)if cmp > -1 thenreturn object.__trueelsereturn object.__falseend
function number_instance:_equal_equal (rhs)if self._lua_number == rhs thenreturn object.__trueelseif type(rhs) == "table" and self._lua_number == rhs._lua_number thenreturn object.__trueelsereturn object.__falseend
function number_instance:_equal_equal(rhs)if self._lua_number == rhs thenreturn object.__trueelseif type(rhs) == "table" and self._lua_number == rhs._lua_number thenreturn object.__trueelsereturn object.__falseend
function number_instance:_less_equal_greater (rhs)if type(rhs) ~= "number" thenerror("Cannot compare number to " .. type(rhs))end
function number_instance:_less_equal_greater(rhs)if type(rhs) ~= "number" thenerror("Cannot compare number to " .. type(rhs))end
if lhs > rhs thenreturn 1elseif lhs < rhs thenreturn -1elseif lhs == rhs thenreturn 0elseerror("Error comparing numbers")end
if lhs > rhs thenreturn 1elseif lhs < rhs thenreturn -1elseif lhs == rhs thenreturn 0elseerror("Error comparing numbers")end
function number_instance:_minus (rhs)if rhs == nil thenreturn -self._lua_numberelseif type(rhs) ~= "number" thenerror("Cannot subtract " .. type(rhs) .. " from number")end
function number_instance:_minus(rhs)if rhs == nil thenreturn -self._lua_numberelseif type(rhs) ~= "number" thenerror("Cannot subtract " .. type(rhs) .. " from number")end
function number_instance:_forward (rhs)if type(rhs) ~= "number" thenerror("Cannot divide number by " .. type(rhs))end
function number_instance:_forward(rhs)if type(rhs) ~= "number" thenerror("Cannot divide number by " .. type(rhs))end
function number_instance:_star (rhs)if type(rhs) ~= "number" thenerror("Cannot multiply number by " .. type(rhs))end
function number_instance:_star(rhs)if type(rhs) ~= "number" thenerror("Cannot multiply number by " .. type(rhs))end
function number_instance:_percent (rhs)if type(rhs) ~= "number" thenerror("Modulo needs a number, not " .. type(rhs))end
function number_instance:_percent(rhs)if type(rhs) ~= "number" thenerror("Modulo needs a number, not " .. type(rhs))end
function number_instance:_up (rhs)if type(rhs) ~= "number" thenerror("Cannot use " .. type(rhs) .. " as an exponent")end
function number_instance:_up(rhs)if type(rhs) ~= "number" thenerror("Cannot use " .. type(rhs) .. " as an exponent")end
function number_instance:times (block)local index = 0local limit = self._lua_numberwhile index < limit doblock(self, index)index = index + 1end
function number_instance:times(block)local index = 0local limit = self._lua_numberwhile index < limit doblock(self, index)index = index + 1end
if is_callable(item) thenwhile i <= num dor[i] = item(self)i = i + 1endelsewhile i <= num dor[i] = itemi = i + 1
if is_callable(item) thenwhile i <= num dor[i] = item(self)i = i + 1endelsewhile i <= num dor[i] = itemi = i + 1end
function number_instance:to (stop, block)local index = self._lua_numberif stop < index thenif block == nil thenlocal a = {}local i = 1local e = math.abs(stop - index) + 1index = index + 1while i <= e doa[i] = index - ii = i + 1end
function number_instance:to(stop, block)local index = self._lua_numberif stop < index thenif block == nil thenlocal a = {}local i = 1local e = math.abs(stop - index) + 1index = index + 1while i <= e doa[i] = index - ii = i + 1end
return array:new(a)elsewhile index >= stop doblock(self, index)index = index - 1endreturn stopendelseif block == nil thenlocal a = {}local i = 1local e = math.abs(stop - index) + 1index = index - 1while i <= e doa[i] = index + ii = i + 1end
return array:new(a)elsewhile index >= stop doblock(self, index)index = index - 1end
local number_native_operations = { _plus = number_instance._plus;_minus = number_instance._minus;_star = number_instance._star;_up = number_instance._up;_percent = number_instance._percent;_forward = number_instance._forward;_less = number_instance._less;_less_greater = number_instance._less_greater;_greater = number_instance._greater;_greater_equal = number_instance._greater_equal;_equal_equal = number_instance._equal_equal }
local number_native_operations = {_plus = number_instance._plus,_minus = number_instance._minus,_star = number_instance._star,_up = number_instance._up,_percent = number_instance._percent,_forward = number_instance._forward,_less = number_instance._less,_less_greater = number_instance._less_greater,_greater = number_instance._greater,_greater_equal = number_instance._greater_equal,_equal_equal = number_instance._equal_equal}
number._unchanged = function (method)return number_native_operations[method] == number_instance[method] and rawget(number, method) == nil
number._unchanged = function(method)return number_native_operations[method] == number_instance[method] and rawget(number, method) == nil
function enumerable:any_question (block)if block == nil thenif self._length == 0 thenreturn object.__falseelsereturn object.__true
function enumerable:any_question(block)if block == nil thenif self._length == 0 thenreturn object.__falseelsereturn object.__trueend
function enumerable:all_question (block)local flag = truelocal f = function (_self, item)if flag and not is_true(block(_self, item)) thenflag = false
function enumerable:all_question(block)local flag = truelocal f = function(_self, item)if flag and not is_true(block(_self, item)) thenflag = falseend
function enumerable:find (block)local found = falselocal f = function (self, item)if not found and is_true(block(self, item)) thenfound = item
function enumerable:find(block)local found = falselocal f = function(self, item)if not found and is_true(block(self, item)) thenfound = itemend
if m == nil thenm = itemelseif t == "table" thenif item:_less_equal_greater(m) == 1 thenm = itemendelseif t == "number" and type(m) == "number" thenif item > m thenm = itemendelseerror(exception:new("Cannot compare " .. tostring(item) .. " to " .. tostring(m)))
if m == nil thenm = itemelseif t == "table" thenif item:_less_equal_greater(m) == 1 thenm = itemendelseif t == "number" and type(m) == "number" thenif item > m thenm = itemendelseerror(exception:new("Cannot compare " .. tostring(item) .. " to " .. tostring(m)))end
function enumerable:min ()local mlocal f = function (self, item)local t = type(item)
function enumerable:min()local mlocal f = function(self, item)local t = type(item)if m == nil thenm = itemelseif t == "table" thenif item:_less_equal_greater(m) == -1 thenm = itemendelseif t == "number" and type(m) == "number" thenif item < m thenm = itemendelseerror(exception:new("Cannot compare " .. tostring(item) .. " to " .. tostring(m)))endendself:each(f)
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)endif not is_true(meth(item)) thennew_array[i] = itemi = i + 1endendelse
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
f = function (_self, item)if not is_true(block(_self, item)) thennew_array[i] = itemi = i + 1end
if not is_true(meth(item)) thennew_array[i] = itemi = i + 1endendelsef = function(_self, item)if not is_true(block(_self, item)) thennew_array[i] = itemi = i + 1endend
if type(first) == "table" and not first._is_an_object and not first.__call_thing and select("#") == 0 thenna._lua_array = firstelsena._lua_array = {first, ...}end
if type(first) == "table" and not first._is_an_object and not first.__call_thing and select("#") == 0 thenna._lua_array = firstelsena._lua_array = { first, ... }end
function array_instance:compact_bang ()local len = self._lengthlocal a = self._lua_arraylocal index = 1local i = 1while index <= len doif a[index] and a[index] ~= object.__null thena[i] = a[index]i = i + 1
function array_instance:compact_bang()local len = self._lengthlocal a = self._lua_arraylocal index = 1local i = 1while index <= len doif a[index] and a[index] ~= object.__null thena[i] = a[index]i = i + 1endindex = index + 1
function array_instance:each_underwhile (block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal res = object.__true
function array_instance:each_underwhile(block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal res = object.__true
function array_instance:each_underuntil (block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal res = object.__false
function array_instance:each_underuntil(block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal res = object.__false
function array_instance:each_underwith_underindex (block)local k = 1local len = self._lengthlocal a = self._lua_array
function array_instance:each_underwith_underindex(block)local k = 1local len = self._lengthlocal a = self._lua_array
function array_instance:deq (item)if self._length == 0 thenreturn object.__nullelselocal res = table.remove(self._lua_array, 1)if res == nil thenres = object.__nullend
function array_instance:deq(item)if self._length == 0 thenreturn object.__nullelselocal res = table.remove(self._lua_array, 1)if res == nil thenres = object.__nullend
function array_instance:flatten ()if self._length == 0 thenreturn array:new({})elselocal first = self._lua_array[1]if type(first) == "table" and first._lua_array thenreturn first:flatten():_plus(self:rest():flatten())
function array_instance:flatten()if self._length == 0 thenreturn array:new({})
return array:new({first}):_plus(self:rest():flatten())
local first = self._lua_array[1]if type(first) == "table" and first._lua_array thenreturn first:flatten():_plus(self:rest():flatten())elsereturn array:new({ first }):_plus(self:rest():flatten())end
function array_instance:flat_undermap (block)if self._length == 0 thenreturn array:new({})elselocal i = 1local len = self._lengthlocal a = self._lua_arraylocal out = {}
function array_instance:flat_undermap(block)if self._length == 0 thenreturn array:new({})elselocal i = 1local len = self._lengthlocal a = self._lua_arraylocal out = {}
while i <= len dolocal res = block(self, a[i])if type(res) == "table" and res._lua_array thenif res._length > 0 thenlocal k = 1while k <= res._length dotable.insert(out, res._lua_array[k])k = k + 1end
while i <= len dolocal res = block(self, a[i])if type(res) == "table" and res._lua_array thenif res._length > 0 thenlocal k = 1while k <= res._length dotable.insert(out, res._lua_array[k])k = k + 1endendelsetable.insert(out, res)endi = i + 1
local f = function(s, item)if type(item) == "number" thentable.insert(out, item)elseif item._lua_array thentable.insert(out, item:pretty(depth + 1))elseif item._lua_string thentable.insert(out, string.format("%q", item._lua_string))elsetable.insert(out, tostring(item))
local f = function(s, item)if type(item) == "number" thentable.insert(out, item)elseif item._lua_array thentable.insert(out, item:pretty(depth + 1))elseif item._lua_string thentable.insert(out, string.format("%q", item._lua_string))elsetable.insert(out, tostring(item))end
if is_callable(block) thenf = blockelseif type(block) == "table" and block._lua_string thenf = function (_self, item)local meth
if is_callable(block) thenf = blockelseif type(block) == "table" and block._lua_string thenf = function(_self, item)local meth
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
local k = 1local i = 1local len = self._lengthlocal a = self._lua_arraywhile k <= len doif not is_true(f(self, a[k])) thena[i] = a[k]i = i + 1
local k = 1local i = 1local len = self._lengthlocal a = self._lua_arraywhile k <= len doif not is_true(f(self, a[k])) thena[i] = a[k]i = i + 1endk = k + 1
function array_instance:reverse_undereach_underwhile (block)local len = self._lengthlocal k = lenlocal a = self._lua_array
function array_instance:reverse_undereach_underwhile(block)local len = self._lengthlocal k = lenlocal a = self._lua_array
if is_callable(block) thenf = blockelseif type(block) == "table" and block._lua_string thenf = function (_self, item)local meth
if is_callable(block) thenf = blockelseif type(block) == "table" and block._lua_string thenf = function(_self, item)local meth
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
if type(item) == "number" thenmeth = number:new(item):get_undermethod(block)elsemeth = item:get_undermethod(block)end
local len = self._lengthlocal a = self._lua_arraylocal k = 1local i = 1while k <= len doif is_true(f(self, a[k])) thena[i] = a[k]i = i + 1end
local len = self._lengthlocal a = self._lua_arraylocal k = 1local i = 1while k <= len doif is_true(f(self, a[k])) thena[i] = a[k]i = i + 1end
if type(item) == "number" thenwhile k <= len doif item == a[k] thenreturn k - 1endk = k + 1endelsewhile k <= len doif is_true(item:_equal_equal(a[k])) thenreturn k - 1endk = k + 1
if type(item) == "number" thenwhile k <= len doif item == a[k] thenreturn k - 1endk = k + 1endelsewhile k <= len doif is_true(item:_equal_equal(a[k])) thenreturn k - 1endk = k + 1end
if type(item) == "number" thenwhile k >= 1 doif item == a[k] thenreturn k - 1endk = k - 1endelsewhile k >= 1 doif is_true(item:_equal_equal(a[k])) thenreturn k - 1endk = k - 1
if type(item) == "number" thenwhile k >= 1 doif item == a[k] thenreturn k - 1endk = k - 1endelsewhile k >= 1 doif is_true(item:_equal_equal(a[k])) thenreturn k - 1endk = k - 1end
function array_instance:map (block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}
function array_instance:map(block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}
if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elselocal m = item[method]if m == nil thenerror("In array.map: " .. tostring(item) .. " has no method called '" .. method .. "'")elseif is_callable(m) thenreturn item[method](item)elsereturn m
if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elselocal m = item[method]if m == nil thenerror("In array.map: " .. tostring(item) .. " has no method called '" .. method .. "'")elseif is_callable(m) thenreturn item[method](item)elsereturn mendend
while k <= len doif a[k] == nil thennew_array[k] = block(self, object.__null)elsenew_array[k] = block(self, a[k])end
while k <= len doif a[k] == nil thennew_array[k] = block(self, object.__null)elsenew_array[k] = block(self, a[k])end
function array_instance:map_underwhile (block)if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elselocal m = item[method]if m == nil thenerror("In array.map: " .. tostring(item) .. " has no method called '" .. method .. "'")elseif is_callable(m) thenreturn item[method](item)elsereturn m
function array_instance:map_underwhile(block)if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elselocal m = item[method]if m == nil thenerror("In array.map: " .. tostring(item) .. " has no method called '" .. method .. "'")elseif is_callable(m) thenreturn item[method](item)elsereturn mendend
local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}
local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}while k <= len dolocal resif a[k] == nil thenres = block(self, object.__null)elseres = block(self, a[k])end
if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function (self, result, item)if type(result) == "number" thenlocal n = number:new(result)return n[method](n, item)elsereturn result[method](result, item)end
if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(self, result, item)if type(result) == "number" thenlocal n = number:new(result)return n[method](n, item)elsereturn result[method](result, item)endend
local len = self._lengthlocal a = self._lua_arraylocal item = nillocal result = identitywhile index <= len doitem = a[index]if item == nil thenitem = object.__null
local len = self._lengthlocal a = self._lua_arraylocal item = nillocal result = identitywhile index <= len doitem = a[index]if item == nil thenitem = object.__nullendresult = block(self, result, item)index = index + 1
if type(item) == "number" thensum = sum + itemelseif item == nil thensum = number.new(sum)._plus(object.__null)elsesum = number.new(sum)._plus(item)end
if type(item) == "number" thensum = sum + itemelseif item == nil thensum = number.new(sum)._plus(object.__null)elsesum = number.new(sum)._plus(item)end
function array_instance:map_bang (block)if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elsereturn item[method](item)end
function array_instance:map_bang(block)if type(block) == "table" and block._lua_string thenlocal method = to_identifier(block._lua_string)block = function(_self, item)if type(item) == "number" thenlocal n = number:new(item)return n[method](n)elsereturn item[method](item)endend
function array_instance:map_underwith_underindex (block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}
function array_instance:map_underwith_underindex(block)local k = 1local len = self._lengthlocal a = self._lua_arraylocal new_array = {}
while k <= len doif a[k] == nil thennew_array[k] = block(self, object.__null, k - 1)elsenew_array[k] = block(self, a[k], k - 1)
while k <= len doif a[k] == nil thennew_array[k] = block(self, object.__null, k - 1)elsenew_array[k] = block(self, a[k], k - 1)endk = k + 1
function array_instance:map_underwith_underindex_bang (block)local k = 1local len = self._lengthlocal a = self._lua_array
function array_instance:map_underwith_underindex_bang(block)local k = 1local len = self._lengthlocal a = self._lua_array
function array_instance:empty_question ()if self._length == 0 thenreturn object.__trueelsereturn object.__falseend
function array_instance:empty_question()if self._length == 0 thenreturn object.__trueelsereturn object.__falseend
function array_instance:first ()if self._length == 0 or self._lua_array[1] == nil thenreturn object.__nullelsereturn self._lua_array[1]end
function array_instance:first()if self._length == 0 or self._lua_array[1] == nil thenreturn object.__nullelsereturn self._lua_array[1]end
function array_instance:last ()if self._length == 0 or self._lua_array[self._length] == nil thenreturn object.__nullelsereturn self._lua_array[self._length]end
function array_instance:last()if self._length == 0 or self._lua_array[self._length] == nil thenreturn object.__nullelsereturn self._lua_array[self._length]end
function array_instance:pop (number)if number == nil thenif self._length == 0 thenreturn object.__null
function array_instance:pop(number)if number == nil thenif self._length == 0 thenreturn object.__nullelselocal res = table.remove(self._lua_array, self._length)if res == nil thenres = object.__nullendself._length = self._length - 1return resend
local res = table.remove(self._lua_array, self._length)if res == nil thenres = object.__nullendself._length = self._length - 1return resendelseif self._length == 0 thenreturn array:new({})elselocal new_array = {}local index = 1local item
if self._length == 0 thenreturn array:new({})elselocal new_array = {}local index = 1local item
while index <= number doitem = table.remove(self._lua_array, self._length)self._length = self._length - 1new_array[index] = item
while index <= number doitem = table.remove(self._lua_array, self._length)self._length = self._length - 1new_array[index] = item
local index = 1local temp = nillocal stop = len / 2local a = self._lua_arraywhile index <= stop dotemp = a[index]a[index] = a[len - index + 1]a[len - index + 1] = tempindex = index + 1end
local index = 1local temp = nillocal stop = len / 2local a = self._lua_arraywhile index <= stop dotemp = a[index]a[index] = a[len - index + 1]a[len - index + 1] = tempindex = index + 1end
local index = 1local a = self._lua_arraylocal b = {}while index <= len dob[index] = a[len - index + 1]index = index + 1end
local index = 1local a = self._lua_arraylocal b = {}while index <= len dob[index] = a[len - index + 1]index = index + 1end
function array_instance:shuffle_bang ()local a = self._lua_arraylocal index = #alocal random_indexlocal templocal random = math.random
function array_instance:shuffle_bang()local a = self._lua_arraylocal index = #alocal random_indexlocal templocal random = math.random
function array_instance:set (index, value)if type(index) ~= "number" thenerror(exception:argument_error("array[]", "valid index", index))end
function array_instance:set(index, value)if type(index) ~= "number" thenerror(exception:argument_error("array[]", "valid index", index))end
function array_instance:get (start_index, end_index)local len = self._lengthif end_index == nil thenif start_index < 0 thenstart_index = len + start_indexend
function array_instance:get(start_index, end_index)local len = self._lengthif end_index == nil thenif start_index < 0 thenstart_index = len + start_indexend
local index = start_indexlocal new_index = 1local new_array = {}local val
while index <= end_index doval = self._lua_array[index + 1]if val == nil thennew_array[new_index] = object.__nullelsenew_array[new_index] = valendindex = index + 1new_index = new_index + 1end
if index < self._length thentable.insert(self._lua_array, index + 1, value)self._length = self._length + 1elseself:set(index, value)end
if index < self._length thentable.insert(self._lua_array, index + 1, value)self._length = self._length + 1elseself:set(index, value)end
function array_instance:join (separator, final)if self._length == 0 thenreturn base_string:new("")elseif self._length == 1 thenreturn base_string:new(tostring(self._lua_array[1]))end
function array_instance:join(separator, final)if self._length == 0 thenreturn base_string:new("")elseif self._length == 1 thenreturn base_string:new(tostring(self._lua_array[1]))end
if final thenreturn base_string:new(table.concat(contents, separator, 1, len - 1) .. final .. contents[len] )elsereturn base_string:new(table.concat(contents, separator))end
if final thenreturn base_string:new(table.concat(contents, separator, 1, len - 1) .. final .. contents[len])elsereturn base_string:new(table.concat(contents, separator))end
function array_instance:concat (arr)if arr._length == 0 thenreturn selfelseif self._length == 0 thenlocal c = arr:copy()self._lua_array = c._lua_arrayself._length = c._length
function array_instance:concat(arr)if arr._length == 0 thenreturn selfelseif self._length == 0 thenlocal c = arr:copy()self._lua_array = c._lua_arrayself._length = c._length
function array_instance:_plus (obj)if type(obj) ~= "table" or obj._lua_array == nil thenerror(exception:argument_error("array.+", "array", tostring(obj)))end
function array_instance:_plus(obj)if type(obj) ~= "table" or obj._lua_array == nil thenerror(exception:argument_error("array.+", "array", tostring(obj)))end
function array_instance:_equal_equal (rhs)if type(rhs) ~= "table" or rhs._lua_array == nil thenreturn object.__falseelseif rhs._lua_array == self._lua_array thenreturn object.__trueelseif rhs._length ~= self._length thenreturn object.__falseelselocal k = 1local lhs = self._lua_arraylocal rhs = rhs._lua_arraylocal len = self._lengthlocal match = truewhile k <= len dolocal vr = rhs[k]local vl = lhs[k]
function array_instance:_equal_equal(rhs)if type(rhs) ~= "table" or rhs._lua_array == nil thenreturn object.__falseelseif rhs._lua_array == self._lua_array thenreturn object.__trueelseif rhs._length ~= self._length thenreturn object.__falseelselocal k = 1local lhs = self._lua_arraylocal rhs = rhs._lua_arraylocal len = self._lengthlocal match = truewhile k <= len dolocal vr = rhs[k]local vl = lhs[k]if vr ~= vl thenlocal tr = type(vr)local tl = type(vl)
if vr ~= vl thenlocal tr = type(vr)local tl = type(vl)
if tr == "table" andtl == "table" andvl._is_an_object andvr._is_an_object andis_true(vl:_equal_equal(vr)) then--nextelseif vl == nil and vr == object.__null then--nextelseif vr == nil and vl == object.__null then--nextelsematch = falsebreakendend
function array_instance:delete_underfirst (item)local a = self._lua_arraylocal len = self._lengthif len == 0 thenreturn selfend
function array_instance:delete_underfirst(item)local a = self._lua_arraylocal len = self._lengthif len == 0 thenreturn selfendlocal found = falselocal k = 0while k <= len doif a[k] == item thenfound = truebreakelseif type(a[k]) == "table" and a[k]._is_an_object and a[k]:_equal_equal(item) thenfound = truebreakend
function array_instance:include_question (item)local a = self._lua_arraylocal len = self._lengthif len == 0 thenreturn object.__falseend
function array_instance:include_question(item)local a = self._lua_arraylocal len = self._lengthif len == 0 thenreturn object.__falseend
local found = falselocal k = 0while k <= len doif type(a[k]) == "table" and a[k]._is_an_object thenif is_true(a[k]:_equal_equal(item)) thenfound = truebreakendelseif a[k] == item thenfound = truebreak
local found = falselocal k = 0while k <= len doif type(a[k]) == "table" and a[k]._is_an_object thenif is_true(a[k]:_equal_equal(item)) thenfound = truebreakendelseif a[k] == item thenfound = truebreakendk = k + 1
function array_instance:unique ()local h = hash:new()local a = self._lua_arraylocal len = self._lengthlocal itemlocal index = 1
function array_instance:unique()local h = hash:new()local a = self._lua_arraylocal len = self._lengthlocal itemlocal index = 1
function array_instance:unique_bang ()local h = hash:new()local a = self._lua_arraylocal len = self._lengthlocal itemlocal index = 1
function array_instance:unique_bang()local h = hash:new()local a = self._lua_arraylocal len = self._lengthlocal itemlocal index = 1
function hash:new (arg)local nh = new_brat(self)nh._length = nil
function hash:new(arg)local nh = new_brat(self)nh._length = nilif type(arg) == "table" and arg._lua_hash thennh._lua_hash = arg._lua_hashnh._key_hash = arg._key_hashelseif type(arg) == "table" thenlocal key_map = {}local keyfor k, v in pairs(arg) doif type(k) == "table" and type(k.__hash) == "function" thenkey = k:__hash()key_map[key] = kendend
if type(arg) == "table" and arg._lua_hash thennh._lua_hash = arg._lua_hashnh._key_hash = arg._key_hashelseif type(arg) == "table" thenlocal key_map = {}local keyfor k,v in pairs(arg) doif type(k) == "table" and type(k.__hash) == "function" thenkey = k:__hash()key_map[key] = kend
nh._lua_hash = argnh._key_hash = key_mapelseif arg == nil thennh._lua_hash = {}nh._key_hash = {}elseerror("argument error")
function hash_instance:_equal_equal (rhs)if self == rhs thenreturn object.__trueelseif type(rhs) ~= "table" or rhs._lua_hash == nil thenreturn object.__falseelseif self:length() ~= rhs:length() thenreturn object.__falseelselocal vr
function hash_instance:_equal_equal(rhs)if self == rhs thenreturn object.__trueelseif type(rhs) ~= "table" or rhs._lua_hash == nil thenreturn object.__falseelseif self:length() ~= rhs:length() thenreturn object.__falseelselocal vr
for k,v in pairs(self._lua_hash) dovr = rhs:get(k)if type(v) == "table" and v._equal_equal thenif not is_true(v:_equal_equal(vr)) thenreturn object.__false
for k, v in pairs(self._lua_hash) dovr = rhs:get(k)if type(v) == "table" and v._equal_equal thenif not is_true(v:_equal_equal(vr)) thenreturn object.__falseendelseif v ~= vr thenreturn object.__falseend
function hash_instance:get (index)local val = self._lua_hash[index]if val thenreturn valelseif type(index) == "table" and type(index.__hash) == "function" thenindex = self._key_hash[index:__hash()]val = self._lua_hash[index]
function hash_instance:get(index)local val = self._lua_hash[index]
return valendelseif type(index) == "string" thenindex = self._key_hash[index]val = self._lua_hash[index]
return valelseif type(index) == "table" and type(index.__hash) == "function" thenindex = self._key_hash[index:__hash()]val = self._lua_hash[index]
function hash_instance:set (index, value)if type(index) == "table" and type(index.__hash) == "function" thenlocal key = index:__hash()if self._key_hash[key] thenself._lua_hash[self._key_hash[key]] = nilend
function hash_instance:set(index, value)if type(index) == "table" and type(index.__hash) == "function" thenlocal key = index:__hash()if self._key_hash[key] thenself._lua_hash[self._key_hash[key]] = nilend
self._key_hash[key] = indexelseif type(index) == "string" thenlocal key = indexif self._key_hash[key] thenindex = self._key_hash[key]elseindex = base_string:new(key)self._key_hash[key] = index
self._key_hash[key] = indexelseif type(index) == "string" thenlocal key = indexif self._key_hash[key] thenindex = self._key_hash[key]elseindex = base_string:new(key)self._key_hash[key] = indexend
function hash_instance:delete (index)if type(index) == "table" and type(index.__hash) == "function" thenlocal key = index:__hash()index = self._key_hash[key]self._key_hash[key] = nilend
function hash_instance:delete(index)if type(index) == "table" and type(index.__hash) == "function" thenlocal key = index:__hash()index = self._key_hash[key]self._key_hash[key] = nilend
function hash_instance:map (block)local a = {}local i = 1for k,v in pairs(self._lua_hash) doa[i] = block(self, k, v)i = i + 1end
function hash_instance:map(block)local a = {}local i = 1for k, v in pairs(self._lua_hash) doa[i] = block(self, k, v)i = i + 1end
function hash_instance:_plus (rhs)if type(rhs) ~= "table" or rhs._lua_hash == nil thenerror(exception:argument_error("hash.+", "hash", tostring(rhs)))end
function hash_instance:_plus(rhs)if type(rhs) ~= "table" or rhs._lua_hash == nil thenerror(exception:argument_error("hash.+", "hash", tostring(rhs)))end
function hash_instance:__hash ()local h = {}local i = 1for k,v in pairs(self._lua_hash) doh[i] = tostring(k) .. tostring(v)i = i + 1end
function hash_instance:__hash()local h = {}local i = 1for k, v in pairs(self._lua_hash) doh[i] = tostring(k) .. tostring(v)i = i + 1end
function hash_instance:keys ()local keys = {}local index = 1for k,v in pairs(self._lua_hash) dokeys[index] = kindex = index + 1end
function hash_instance:keys()local keys = {}local index = 1for k, v in pairs(self._lua_hash) dokeys[index] = kindex = index + 1end
function hash_instance:values ()local values = {}local index = 1for k,v in pairs(self._lua_hash) dovalues[index] = vindex = index + 1end
function hash_instance:values()local values = {}local index = 1for k, v in pairs(self._lua_hash) dovalues[index] = vindex = index + 1end
function hash_instance:select (block)local result = {}for k,v in pairs(self._lua_hash) doif is_true(block(self, k, v)) thenresult[k] = v
function hash_instance:select(block)local result = {}for k, v in pairs(self._lua_hash) doif is_true(block(self, k, v)) thenresult[k] = vend
function hash_instance:empty_question ()if next(self._lua_hash) == nil thenself._length = 0return object.__trueelsereturn object.__falseend
function hash_instance:empty_question()if next(self._lua_hash) == nil thenself._length = 0return object.__trueelsereturn object.__falseend
function hash_instance:key_question (item)local val = self._lua_hash[item]if val thenreturn object.__trueelseif type(item) == "table" and type(item.__hash) == "function" thenitem = self._key_hash[item:__hash()]val = self._lua_hash[item]
function hash_instance:key_question(item)local val = self._lua_hash[item]if val thenreturn object.__trueelseif type(item) == "table" and type(item.__hash) == "function" thenitem = self._key_hash[item:__hash()]val = self._lua_hash[item]
local contents = {}local i = 1for k,v in pairs(self._lua_hash) docontents[i] = tostring(k) .. ": " .. tostring(v)i = i + 1end
local contents = {}local i = 1for k, v in pairs(self._lua_hash) docontents[i] = tostring(k) .. ": " .. tostring(v)i = i + 1end
if i == 1 thenreturn base_string:new("[:]")elsereturn base_string:new("[" .. table.concat(contents, ", ") .. "]")end
if i == 1 thenreturn base_string:new("[:]")elsereturn base_string:new("[" .. table.concat(contents, ", ") .. "]")end
function hash_instance:_unchanged (method)return hash_native_methods[method] == hash_instance[method] and rawget(hash, method) == nil
function hash_instance:_unchanged(method)return hash_native_methods[method] == hash_instance[method] and rawget(hash, method) == nil
elseif type(s) == "table" thenif s._lua_string == nil thenerror("error")elsens._lua_string = s._lua_string
if type(s) == "string" thenns._lua_string = selseif type(s) == "table" thenif s._lua_string == nil thenerror("error")elsens._lua_string = s._lua_stringend
function string_instance:each_underline (block)local pos = 1local s = self._lua_stringlocal s_endlocal resultif block == nil thenresult = {}end
function string_instance:each_underline(block)local pos = 1local s = self._lua_stringlocal s_endlocal resultif block == nil thenresult = {}end
while s_end doif block thenblock(self, base_string:new(s:sub(pos, s_end - 1)))elsetable.insert(result, base_string:new(s:sub(pos, s_end - 1)))
while s_end doif block thenblock(self, base_string:new(s:sub(pos, s_end - 1)))elsetable.insert(result, base_string:new(s:sub(pos, s_end - 1)))endpos = s_end + 1s_end = s:find("\n", pos, true)
function string_instance:empty_question ()if #self._lua_string == 0 thenreturn object.__trueelsereturn object.__falseend
function string_instance:empty_question()if #self._lua_string == 0 thenreturn object.__trueelsereturn object.__falseend
function string_instance:strip_bang ()self._lua_string = orex.gsub(self._lua_string, string_instance.__stripper, "")return self
function string_instance:strip_bang()self._lua_string = orex.gsub(self._lua_string, string_instance.__stripper, "")return self
function string_instance:alpha_question ()if self._lua_string:match("^%a+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:alpha_question()if self._lua_string:match("^%a+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:alphanum_question ()if self._lua_string:match("^%w+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:alphanum_question()if self._lua_string:match("^%w+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:numeric_question ()if self._lua_string:match("^-?%d+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:numeric_question()if self._lua_string:match("^-?%d+$") thenreturn object.__trueelsereturn object.__falseend
function string_instance:_equal_equal (rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenreturn object.__falseelseif self._lua_string == rhs._lua_string thenreturn object.__trueelsereturn object.__falseend
function string_instance:_equal_equal(rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenreturn object.__falseelseif self._lua_string == rhs._lua_string thenreturn object.__trueelsereturn object.__falseend
function string_instance:_less_equal_greater (rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenerror(exception:new("Cannot compare string to " .. tostring(rhs)))end
function string_instance:_less_equal_greater(rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenerror(exception:new("Cannot compare string to " .. tostring(rhs)))end
if lhs > rhs thenreturn 1elseif lhs < rhs thenreturn -1elseif lhs == rhs thenreturn 0elseerror("Error comparing strings")end
if lhs > rhs thenreturn 1elseif lhs < rhs thenreturn -1elseif lhs == rhs thenreturn 0elseerror("Error comparing strings")end
function string_instance:_plus (rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenerror("Cannot add string to non-string")end
function string_instance:_plus(rhs)if type(rhs) ~= "table" or rhs._lua_string == nil thenerror("Cannot add string to non-string")end
function string_instance:include_question (pattern)if type(pattern) == "table" thenif pattern._lua_regex thenif is_true(self:match(pattern)) thenreturn object.__trueelsereturn object.__falseendelseif pattern._lua_string thenif string.find(self._lua_string, pattern._lua_string, 1, true) thenreturn object.__trueelsereturn object.__falseend
function string_instance:include_question(pattern)if type(pattern) == "table" thenif pattern._lua_regex thenif is_true(self:match(pattern)) thenreturn object.__trueelsereturn object.__falseendelseif pattern._lua_string thenif string.find(self._lua_string, pattern._lua_string, 1, true) thenreturn object.__trueelsereturn object.__falseendend
function string_instance:match (regx, start_index)if type(regx) ~= "table" or regx._lua_regex == nil thenerror(exception:argument_error("string.match", "regex", tostring(regx)))end
function string_instance:match(regx, start_index)if type(regx) ~= "table" or regx._lua_regex == nil thenerror(exception:argument_error("string.match", "regex", tostring(regx)))end
function string_instance:sub (pattern, replacement, limit)local pattern_typeif type(pattern) == "table" thenif pattern._lua_string thenpattern_type = "string"pattern = pattern._lua_stringelseif pattern._lua_regex thenpattern_type = "regex"pattern = pattern._lua_regex
function string_instance:sub(pattern, replacement, limit)local pattern_typeif type(pattern) == "table" thenif pattern._lua_string thenpattern_type = "string"pattern = pattern._lua_stringelseif pattern._lua_regex thenpattern_type = "regex"pattern = pattern._lua_regexelseerror(exception:argument_error("string.sub", "regular expression", tostring(pattern)))end
if is_callable(replacement) thenlocal f = replacementreplacement = function (s)local s = base_string:new(s)local r = f(s,s)if r._lua_string thenreturn r._lua_stringelseif r == object.__null thenreturn nilelsereturn rendendelseif type(replacement) == "table" thenif replacement._lua_string thenreplacement = replacement._lua_stringelseif replacement._lua_hash thenlocal r = {}for k,v in pairs(replacement._lua_hash) dor[k._lua_string] = v._lua_stringendreplacement = r
if is_callable(replacement) thenlocal f = replacementreplacement = function(s)local s = base_string:new(s)local r = f(s, s)if r._lua_string thenreturn r._lua_stringelseif r == object.__null thenreturn nilelsereturn rendendelseif type(replacement) == "table" thenif replacement._lua_string thenreplacement = replacement._lua_stringelseif replacement._lua_hash thenlocal r = {}for k, v in pairs(replacement._lua_hash) dor[k._lua_string] = v._lua_stringendreplacement = relseerror(exception:argument_error("string.sub", "string", tostring(replacement)))end
local nsif pattern_type == "regex" thenns = orex.gsub(self._lua_string, pattern, replacement, limit)elsens = self._lua_string:gsub(pattern, replacement, limit)end
local nsif pattern_type == "regex" thenns = orex.gsub(self._lua_string, pattern, replacement, limit)elsens = self._lua_string:gsub(pattern, replacement, limit)end
function string_instance:sub_bang (pattern, replacement, limit)if type(pattern) ~= "table" or not pattern._lua_regex thenerror(exception:argument_error("string.sub!", "regular expression", tostring(pattern)))elseif (type(replacement) == "table" and replacement._lua_string == nil) and not is_callable(replacement) thenerror(exception:argument_error("string.sub!", "string", tostring(replacement)))end
function string_instance:sub_bang(pattern, replacement, limit)if type(pattern) ~= "table" or not pattern._lua_regex thenerror(exception:argument_error("string.sub!", "regular expression", tostring(pattern)))elseif (type(replacement) == "table" and replacement._lua_string == nil) and not is_callable(replacement) thenerror(exception:argument_error("string.sub!", "string", tostring(replacement)))end
function string_instance:_star (num)if type(num) ~= "number" thenerror(exception:argument_error("string.*", "number", tostring(num)))end
function string_instance:_star(num)if type(num) ~= "number" thenerror(exception:argument_error("string.*", "number", tostring(num)))end
function string_instance:find_underfirst (str)local s_index, e_index = self._lua_string:find(str._lua_string, 1, true)
function string_instance:find_underfirst(str)local s_index, e_index = self._lua_string:find(str._lua_string, 1, true)
function string_instance:find_underall (str)local search_string = str._lua_stringlocal current_index = 1local finds = {}
function string_instance:find_underall(str)local search_string = str._lua_stringlocal current_index = 1local finds = {}
function string_instance:get (start_index, end_index)local len = #self._lua_stringif end_index == nil thenif start_index < 0 thenstart_index = len + start_indexend
function string_instance:get(start_index, end_index)local len = #self._lua_stringif end_index == nil thenif start_index < 0 thenstart_index = len + start_indexend
local val = string.sub(self._lua_string, start_index + 1, start_index + 1)if val == nil thenreturn object.__null
local val = string.sub(self._lua_string, start_index + 1, start_index + 1)if val == nil thenreturn object.__nullelsereturn base_string:new(val)end
if index > len thenerror(exception:new("Index " .. tostring(index) .. " is greater than length of string (" .. tostring(len) .. ")"))elseif index < 0 thenerror(exception:new("Index " .. tostring(index) .. " is outside the string"))elseif type(value) ~= "table" or value._lua_string == nil thenerror(exception:argument_error("string[]", "string", tostring(value)))elseif type(index) ~= "number" thenerror(exception:argument_error("string[]", "number", tostring(value)))end
if index > len thenerror(exception:new("Index " .. tostring(index) .. " is greater than length of string (" .. tostring(len) .. ")"))elseif index < 0 thenerror(exception:new("Index " .. tostring(index) .. " is outside the string"))elseif type(value) ~= "table" or value._lua_string == nil thenerror(exception:argument_error("string[]", "string", tostring(value)))elseif type(index) ~= "number" thenerror(exception:argument_error("string[]", "number", tostring(value)))end
local original = self._lua_stringlocal front = string.sub(original, 0, index)local back = string.sub(original, index + 2, -1)self._lua_string = front .. value._lua_string .. back
local original = self._lua_stringlocal front = string.sub(original, 0, index)local back = string.sub(original, index + 2, -1)self._lua_string = front .. value._lua_string .. back
function string_instance:split (sep)if sep == nil thensep = orex.new("\\s+")elseif type(sep) == "table" thenif sep._lua_string thensep = orex.new(sep._lua_string, nil, nil, "ASIS")elseif sep._lua_regex thensep = sep._lua_regex
function string_instance:split(sep)if sep == nil thensep = orex.new("\\s+")elseif type(sep) == "table" thenif sep._lua_string thensep = orex.new(sep._lua_string, nil, nil, "ASIS")elseif sep._lua_regex thensep = sep._lua_regexendelseif type(sep) ~= "string" thenerror(exception:argument_error("string.split", "string or regex", tostring(sep)))
local result = {}local i = 1for value in orex.split(self._lua_string, sep) doif value and value ~= "" thenresult[i] = base_string:new(value)i = i + 1
local result = {}local i = 1for value in orex.split(self._lua_string, sep) doif value and value ~= "" thenresult[i] = base_string:new(value)i = i + 1end
function string_instance:_less_less (value)if type(value) ~= "table" or value._lua_string == nil thenerror(exception:argument_error("string <<", "string", tostring(value)))end
function string_instance:_less_less(value)if type(value) ~= "table" or value._lua_string == nil thenerror(exception:argument_error("string <<", "string", tostring(value)))end
function string_instance:to_underi (base)local n = tonumber(self._lua_string, base)if n thenreturn math.floor(n)elsereturn object.__nullend
function string_instance:to_underi(base)local n = tonumber(self._lua_string, base)if n thenreturn math.floor(n)elsereturn object.__nullend
function string_instance:to_underbyte ()if #self._lua_string == 1 thenreturn self._lua_string:byte()elsereturn array:new(self._lua_string:byte(1, #self._lua_string))end
function string_instance:to_underbyte()if #self._lua_string == 1 thenreturn self._lua_string:byte()elsereturn array:new(self._lua_string:byte(1, #self._lua_string))end
elseif type(s) == "table" thenif s._lua_string == nil thenerror("error")elsens._lua_string = s._lua_string
if type(s) == "string" thenns._lua_string = selseif type(s) == "table" thenif s._lua_string == nil thenerror("error")elsens._lua_string = s._lua_stringend
function regex_match:init (start_pos, end_pos, full_match, matches)self.start_underpos = start_posself.end_underpos = end_posself.full_undermatch = full_matchself.matches = matches
function regex_match:init(start_pos, end_pos, full_match, matches)self.start_underpos = start_posself.end_underpos = end_posself.full_undermatch = full_matchself.matches = matches
function regex:new (string, options)if type(string) == "string" thenelseif type(string) == "table" and string._lua_string ~= nil thenstring = string._lua_stringelseerror(exception:argument_error("regex.new", "string", string))end
function regex:new(string, options)if type(string) == "string" thenelseif type(string) == "table" and string._lua_string ~= nil thenstring = string._lua_stringelseerror(exception:argument_error("regex.new", "string", string))end
if options == nil or type(options) == "string" thenelseif type(options) == "table" and options._lua_string ~= nil thenoptions = options._lua_stringelseerror(exception:argument_error("regex.new", "string", string))end
if options == nil or type(options) == "string" thenelseif type(options) == "table" and options._lua_string ~= nil thenoptions = options._lua_stringelseerror(exception:argument_error("regex.new", "string", string))end
function regex_instance:match (string, start_index)if type(string) == "string" thenelseif type(string) == "table" and string._lua_string ~= nil thenstring = string._lua_stringelseerror(exception:argument_error("regex.match", "string", string))end
function regex_instance:match(string, start_index)if type(string) == "string" thenelseif type(string) == "table" and string._lua_string ~= nil thenstring = string._lua_stringelseerror(exception:argument_error("regex.match", "string", string))end
if result[3] thenlocal k = 3local vwhile k <= #result dov = result[k]if type(v) == "string" thenr[k - 1] = base_string:new(v)elseif v == false thenr[k - 1] = object.__falseend
if result[3] thenlocal k = 3local vwhile k <= #result dov = result[k]if type(v) == "string" thenr[k - 1] = base_string:new(v)elseif v == false thenr[k - 1] = object.__falseend
local msg = base_string:new(message)local stack_trace = base_string:new(debug.traceback(message, 2))error_type = base_string:new(error_type)
local msg = base_string:new(message)local stack_trace = base_string:new(debug.traceback(message, 2))error_type = base_string:new(error_type)
e.error_undermessage = function () return msg ende.stack_undertrace = function()return stack_traceende.type = function() return error_type endreturn e
e.error_undermessage = function() return msg ende.stack_undertrace = function()return stack_traceende.type = function() return error_type endreturn e
function exception._handler (exp)if type(exp) == "table" and exp.stack_undertrace thenprint(exp:stack_undertrace())elseprint(debug.traceback(exp, 3))endreturn nil
function exception._handler(exp)if type(exp) == "table" and exp.stack_undertrace thenprint(exp:stack_undertrace())elseprint(debug.traceback(exp, 3))endreturn nil
function exception_instance:to_unders ()if self.error_undermessage ~= nil thenreturn self.error_undermessage()elsereturn base_string:new("Generic error")end
function exception_instance:to_unders()if self.error_undermessage ~= nil thenreturn self.error_undermessage()elsereturn base_string:new("Generic error")end
function exception:argument_undererror (method, expected, given)return self:new("Argument error: " .. tostring(method) .. " expected " .. tostring(expected) .. " argument(s) but was given " .. tostring(given) .. ".", "argument error")
function exception:argument_undererror(method, expected, given)return self:new("Argument error: " ..tostring(method) .. " expected " .. tostring(expected) .. " argument(s) but was given " .. tostring(given) .. ".","argument error")
function exception:method_undererror (object, method_name)return self:new("Method error: " .. tostring(object) .. " has no method called '" .. tostring(method_name) .. "'.", "method error")
function exception:method_undererror(object, method_name)return self:new("Method error: " .. tostring(object) .. " has no method called '" .. tostring(method_name) .. "'.","method error")
function exception:null_undererror (name, cannot)return self:new("Null error: " .. tostring(name) .. " is null, cannot " .. tostring(cannot) .. ".", "null error")
function exception:null_undererror(name, cannot)return self:new("Null error: " .. tostring(name) .. " is null, cannot " .. tostring(cannot) .. ".", "null error")
function exception:name_undererror (name)return self:new("Name error: No such method or local variable '" .. tostring(name) .. "'.", "name error")
function exception:name_undererror(name)return self:new("Name error: No such method or local variable '" .. tostring(name) .. "'.", "name error")
function object:_compile (name)local check_and_compile = function (self, path)if type(path) == "table" and path._lua_string thenpath = path._lua_stringend
function object:_compile(name)local check_and_compile = function(self, path)if type(path) == "table" and path._lua_string thenpath = path._lua_stringend
local file_name = path .. "/" .. namelocal lua_modified = lfs.attributes(file_name .. ".lua", "modification")local brat_modified = lfs.attributes(file_name .. ".brat", "modification")
local file_name = path .. "/" .. namelocal lua_modified = lfs.attributes(file_name .. ".lua", "modification")local brat_modified = lfs.attributes(file_name .. ".brat", "modification")
if brat_modified thenif lua_modified == nil or brat_modified > lua_modified thenif not is_true(_compiling:include_question(file_name)) then_compiling:_less_less(file_name)compile_file(file_name)_compiling:delete_underfirst(file_name)
if brat_modified thenif lua_modified == nil or brat_modified > lua_modified thenif not is_true(_compiling:include_question(file_name)) then_compiling:_less_less(file_name)compile_file(file_name)_compiling:delete_underfirst(file_name)endend
function object:argv ()if object._argv == nil thenlocal f = function (self, a)return base_string:new(a)
function object:argv()if object._argv == nil thenlocal f = function(self, a)return base_string:new(a)endobject._argv = array:new(arg):map_bang(f)