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 function dummy()end | |
local funcmt = getmetatable(dummy) | |
if not funcmt then | |
funcmt = {} | |
debug.setmetatable(dummy,funcmt) | |
end | |
funcmt.__index = funcmt.__index or {} | |
local type,select = type,select | |
assert(type(funcmt.__index) == "table") | |
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
function SegmentCircleIntersect(a, b, c) | |
local ac2 = (c.x - a.x)^2 + (c.y - a.y)^2 | |
local cr2 = c.r * c.r | |
if ac2 <= cr2 then | |
return a | |
end | |
local bc2 = (c.x - b.x)^2 + (c.y - b.y)^2 | |
if bc2 <= cr2 then | |
return b |
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 bylen = {} | |
for i=1,99 do bylen[i] = {} end | |
for word in io.lines("/usr/share/dict/words") do | |
if #word % 2 == 0 then | |
local bucket = bylen[#word] | |
bucket[#bucket+1] = word:lower() | |
end | |
end | |
for i=2,99,2 do |
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 function arr_to_set(t) | |
local ret = {} | |
for k,v in ipairs(t) do | |
ret[v] = true | |
end | |
return ret | |
end | |
local check_31 = arr_to_set{1,13,17,29,37,41,49,53} | |
local check_32 = arr_to_set{7,19,31,43} |
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
Janet 1.7.0-f7ee8bd Copyright (C) 2017-2019 Calvin Rose | |
janet:1:> (defn my_fn [] (for i 0 10 (yield i))) | |
<function my_fn> | |
janet:2:> (defn coroutine-clone [co] (unmarshal (marshal co make-image-dict) load-image-dict)) | |
<function coroutine-clone> | |
janet:3:> (def a (coro (my_fn))) | |
<fiber 0x00580A80> | |
janet:4:> (resume a) | |
0 | |
janet:5:> (resume a) |
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 co_stack = {} | |
local co_running = {} | |
local n_cos = 0 | |
local real_yield = coroutine.yield | |
local real_resume = coroutine.resume | |
local real_status = coroutine.status | |
local real_create = coroutine.create | |
local co_wrap_resume | |
local co_wrap_loop |
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 co_stack = {} | |
local co_running = {} | |
local n_cos = 0 | |
local real_yield = coroutine.yield | |
local real_resume = coroutine.resume | |
local real_status = coroutine.status | |
local real_create = coroutine.create | |
local co_wrap_resume | |
local co_wrap_loop |
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 ffi = require("ffi") | |
ffi.cdef[[ | |
int SDL_GL_MakeCurrent(void* window,void* context); | |
void* SDL_GL_GetCurrentContext(void); | |
void* SDL_GL_GetCurrentWindow(void); | |
]] | |
function love.load() |
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
-- The Computer Language Benchmarks Game | |
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/ | |
-- contributed by Mike Pall (with ideas from Rici Lake) | |
-- modified for 5.3 by Robin | |
-- multithread by sharpobject | |
-- arg[2] = worker id if we are a worker, absent if we are the main process | |
local is_worker = arg[2] | |
local always_output = is_worker == "1" |
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 debug = debug | |
local coroutine = coroutine | |
local type = type | |
local next = next | |
local pairs = pairs | |
local package = package | |
-- todo: lightuserdata? | |
local all_types = { | |
1, |
OlderNewer