Skip to content

Instantly share code, notes, and snippets.

@robotlolita
robotlolita / multiple-delegation.js
Created November 23, 2011 21:59
multiple delegation
var boo = require('boo')
var Delegate = {
// Makes the given property a getter, that will try the
// objects in order until it finds a suitable one.
//
// proxy :: String → Object
@andyhd
andyhd / maybe-monad.js
Created January 16, 2012 01:02
Maybe monad in Javascript
function maybe(value) {
var obj = null;
function isEmpty() { return value === undefined || value === null }
function nonEmpty() { return !isEmpty() }
obj = {
map: function (f) { return isEmpty() ? obj : maybe(f(value)) },
getOrElse: function (n) { return isEmpty() ? n : value },
isEmpty: isEmpty,
nonEmpty: nonEmpty
}