Last active
August 29, 2015 14:09
-
-
Save Seberius/3716a84fda8529890dd8 to your computer and use it in GitHub Desktop.
ClojureScript Factory Pattern Example
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
(definterface IBigInt | |
(add this y) | |
(subtract this y) | |
(multiply this y) | |
(divide this y)) | |
(defprotocol BigInt [signum magnitude] | |
IBigInt | |
(add (add this y)) | |
(subtract (sub this y)) | |
(multiply (mul this y)) | |
(divide (div this y))) | |
(defn big-int [num] | |
(if (= (typeof num) "String") | |
(BigInt (sig-from-str num) (mag-from-str num)) | |
(BigInt (sig-from-num num) (mag-from-num num)f))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment