Last active
December 20, 2015 05:29
-
-
Save mattfield/6078866 to your computer and use it in GitHub Desktop.
Maybe functor
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
var Maybe = function(val){ | |
this.val = val; | |
}; | |
Maybe.prototype.map = function(f){ | |
return this.val ? Maybe(f(this.val)) : Maybe(null); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment