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
---------------------------------------------------------------------------------------------------- | |
--- Making Lua look like Prolog: | |
--- | |
--- Let's use metatables for something other than emulating prototype-based OO. By making the | |
--- __index metamethod create values for undefined things, we can make Lua look like Prolog! | |
--- We create empty tables for anything starting with a capital letter, functions that populate | |
--- those tables for lowercase things (to assign relationships) and if a name begins with "is_" | |
--- then it becomes a function that queries those tables. | |
---------------------------------------------------------------------------------------------------- |
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
-- SOR Algorithm Implemented through Lua | |
function Norm(m) | |
local n = 0 | |
for i,v in ipairs(m) do | |
n = n + v^2 | |
end | |
return math.sqrt(n) | |
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
--[[ | |
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php. | |
Example: | |
ProFi = require 'ProFi' | |
ProFi:start() | |
some_function() | |
another_function() | |
coroutine.resume( some_coroutine ) | |
ProFi:stop() |
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
-- A stress test for the pathfinding library Jumper (v1.8.1) | |
-- Source: https://github.com/Yonaba/Jumper/tree/jumper-1.8.1-1 | |
-- The purpose of this is to compare the relative performance of different | |
-- search algorithms implemented in Jumper. Time measurements uses Lua's | |
-- native os.clock with (milliseconds precision). | |
-- Library setup | |
local Grid = require 'jumper.grid' |
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
// A* with Jump Point Search on JavaScript | |
// - python A*: https://gist.github.com/bellbind/147645 | |
// utility: Priority Queue | |
var PQ = function PQ() { | |
return Object.create(PQ.prototype, { | |
array: {value: []}, | |
}); | |
}; | |
PQ.prototype.empty = function () { |
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
-- simple class | |
------------------------------------------------- | |
local mixin_reserved = { | |
['new'] = true, | |
['onMixin'] = true, | |
['__type'] = true, | |
['__index'] = true, | |
} | |
local base = {__type = 'Object'} |
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
--# Main | |
-- A stress test for the pathfinding library Jumper | |
-- https://github.com/Yonaba/Jumper/tree/jumper-1.8.1-1 | |
-- The purpose of this is to compare the relative performance of the different | |
-- search algorithms implemented in Jumper | |
-- Time measurements uses Lua's native os.clock with milliseconds precision | |
function setup() | |
local Grid = grid() |
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
-- Two dashes start a one-line comment. | |
--[[ | |
Adding two ['s and ]'s makes it a | |
multi-line comment. | |
--]] | |
---------------------------------------------------- | |
-- 1. Variables and flow control. | |
---------------------------------------------------- |
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
--[[-- | |
Use this file to specify System preferences. | |
Review [examples](+C:\Dokumente und Einstellungen\dr\Desktop\ZeroBraneStudioEduPack-0.38-win32\cfg\user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details. | |
--]]-- | |
local G = ... | |
styles = G.loadfile('cfg/tomorrow.lua')('Zenburn') -- theme | |
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
-- Calls f(...) n-times | |
local function time(nm,times, f,...) | |
local st = os.clock() | |
for i = 1, times do | |
f(...) | |
end | |
local et = os.clock() | |
print(('(%s): Times (%d): %.2f ms') | |
:format(nm, times, (et-st)*1000)) | |
end |
OlderNewer