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
export function getIn(key, obj, alt) { | |
return key in obj ? obj[key] : alt; | |
} | |
export function getOwn(key, obj, alt) { | |
return obj.hasOwnProperty(key) ? obj[key] : alt; | |
} | |
export function set(key, obj, val) { | |
obj[key] = val; |
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
/** | |
* Partial function application. Fixes the number of arguments to a function, | |
* producing another function of smaller arity. | |
* | |
* @arg {function} fn Target function. | |
* @arg {...*} args Arguments to fix. | |
* @return {function} New function with fixed arguments. | |
*/ | |
const part = (fn, ...args) => fn.bind(undefined, ...args); |
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
// Pseudo-code that implements Cheney's algorithm | |
class Object { | |
// remains null for normal objects | |
// non-null for forwarded objects | |
Object* _forwardee; | |
public: | |
void forward_to(address new_addr); | |
Object* forwardee(); |
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
// noprotect | |
function Returning(k){ | |
var k1 = function(x){ return k(x) } | |
k1.isReturn = true; | |
k1.ori = k; | |
return k1; | |
} | |
function interpret(c, e, k){ | |
if(typeof c === 'string') return k(e[c]); | |
else if(c instanceof Array) switch(c[0]) { |
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(xports) { | |
'use strict'; | |
var noMeth = function () { throw new ReferenceError('No such method'); }; | |
var defProp = Object.defineProperty || function (obj, prop, desc) { | |
return obj[prop] = desc.value; | |
}; | |
var genfun = function (key, defaultFun) { | |
if (!defaultFun) { defaultFun = noMeth; } | |
var appl = function () { | |
var obj = arguments[0]; |