Skip to content

Instantly share code, notes, and snippets.

View buzzdecafe's full-sized avatar
💭
quaquaquaqua

buzzdecafe

💭
quaquaquaqua
View GitHub Profile
@buzzdecafe
buzzdecafe / Lazy.js
Created May 27, 2017 12:36 — forked from i-am-tom/Lazy.js
A Fantasy Land-compliant type for lazy computation.
const fl = require('fantasy-land')
//- Lazy holds a vaue in a thunk, effectively delaying
//- evaluation until required. This is useful when we're
//- in a situation with either very large data set or
//- cyclical data.
//@ make stack-safe.
//> type Lazy a = Unit -> a
function Lazy(run) {
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@buzzdecafe
buzzdecafe / Functor.js
Last active October 18, 2023 07:28 — forked from CrossEye/Functor.js
(function(global) {
global.Functor = function(conf) {
Functor.types[conf.key] = {
obj: conf.obj,
fmap: conf.fmap
};
};
Functor.types = {};
function fail(x) { return []; }
function succeed(x) { return [x]; }
function disj(f1, f2) {
return function(x) {
return f1(x).concat(f2(x));
}
}
function conj(f1, f2) {
@buzzdecafe
buzzdecafe / aaa.js
Last active December 15, 2015 17:29 — forked from AutoSponge/tco.md
function recur(fn) {
return function () {
var bounce = fn.apply(this, arguments);
while (bounce.onTheTrampoline) {
bounce = bounce();
}
return bounce;
};
}
var sum1 = recur(function sum(x, y) {