- Motivating Demonstration:
swap.c
int a = 10;
The venerable master Qc Na was walking with his student, Anton. Hoping to | |
prompt the master into a discussion, Anton said "Master, I have heard that | |
objects are a very good thing - is this true?" Qc Na looked pityingly at | |
his student and replied, "Foolish pupil - objects are merely a poor man's | |
closures." | |
Chastised, Anton took his leave from his master and returned to his cell, | |
intent on studying closures. He carefully read the entire "Lambda: The | |
Ultimate..." series of papers and its cousins, and implemented a small | |
Scheme interpreter with a closure-based object system. He learned much, and |
--[[ ArrayDiff | |
Receives two arrays, and gets the difference between them. Returns a list of | |
steps that will turn the first array into the second. | |
- Elements in each array should be unique | |
- Order of elements matters | |
Ops: | |
insert: {1, index, value} |
-- Replaces Roblox Studio's splash screen with another image. | |
-- | |
-- Usage: | |
-- | |
-- lua splash-patch.lua [STUDIO_PATH] [IMAGE_PATH] | |
-- | |
-- Specifying no options prompts for input. | |
-- First KB of original splash image file |
#define _CRT_SECURE_NO_WARNINGS | |
#include <vector> | |
#include <memory> | |
#include <future> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <time.h> | |
#include <stdint.h> |
local ClassName = 'TextButton' | |
local Object = game.Selection:Get()[1] | |
local HttpService = game:GetService('HttpService') | |
local API = HttpService:JSONDecode(HttpService:GetAsync('http://anaminus.github.io/rbx/json/api/latest.json')) | |
local function ChangeClass(ClassName, Object, NewObject) | |
for _,v in next,API do | |
if (v['type'] == 'Class' and v['Name'] == ClassName and v['Superclass']) then | |
ChangeClass(v['Superclass'], Object, NewObject) | |
elseif (v['type'] == 'Property' and v['Class'] == ClassName) then | |
pcall(function() -- If property is not allowed to be changed, do not error. |
// Can be used to efficiently encode floating point values from a limited range ([0..65k]) into a byte | |
// edgeDecode is optimized for GPUs (native exp2) | |
// edgeEncode1 is optimized for GPUs (native log2) | |
// edgeEncode2 is optimized for CPUs but is an approximation | |
// edgeEncode3 is optimized for CPUs | |
float edgeDecode(int e) | |
{ | |
return exp2f(float(e) * (1 / 16.f)) - 1; | |
} |
--[[ | |
# Signal | |
API-compatible Roblox events. | |
Addresses two flaws in previous implementations: | |
- Held a reference to the last set of fired arguments. | |
- Arguments would be overridden if the signal was fired by a listener. |
local Roact = require("Roact") | |
local Segments = {} | |
for index = 1, 8 do | |
local X = (index - 1) % 4 | |
local Y = math.floor((index - 1) / 4) | |
table.insert(Segments, { | |
Angle = 360 / (2 ^ index), |
--- | |
-- @module WaveCollapseUtils | |
-- @author Quenty | |
local WaveCollapseUtils = {} | |
local EDGE_DATA = { | |
{ | |
2, -- Edge index (forward) | |
1, -- Neighbor's edgeindex (backward) |