Created
November 2, 2013 10:39
-
-
Save dancek/7277624 to your computer and use it in GitHub Desktop.
Playing around with the idea of function annotations in Coffeescript
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
ㅡid = (f) -> f | |
ㅡmemoize = (f) -> | |
window._vals = {} | |
(args...) -> | |
_args = args.join 'ㅡ' | |
if _args of _vals | |
return _vals[_args] | |
val = f args... | |
_vals[_args] = val | |
return val | |
f = | |
ㅡmemoize \ | |
(x) -> | |
console.log "running! x=#{x}" | |
Math.sqrt x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment