Created
June 11, 2012 11:27
-
-
Save wfaler/2909653 to your computer and use it in GitHub Desktop.
option in Clojure
This file contains hidden or 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
(defn get-or-else [value default] | |
(if (nil? value) | |
(if (ifn? default) | |
(default) | |
default) | |
value)) | |
(defn m-bind [value function] | |
(if (nil? value) | |
nil | |
(function value))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment