Last active
August 29, 2015 14:07
-
-
Save donnut/d9d9be2361797740d171 to your computer and use it in GitHub Desktop.
deep copy prototype
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
Prototypical description of a deep copy method | |
deepCopy:: a -> b | |
copyDate:: Date -> Date | |
a == Number ? s = a: | |
a == String ? b = a: | |
a == Boolean ? b = a: | |
a == Function ? b = a: // remains by reference | |
a == Date ? b = copyDate a: | |
a == Object ? b = deepCopy a.keys[]: | |
a == Array ? (a:as) => b = deepCopy a, deepCopy as | |
- circular references |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment