Skip to content

Instantly share code, notes, and snippets.

@dancek
Created November 2, 2013 10:39
Show Gist options
  • Save dancek/7277624 to your computer and use it in GitHub Desktop.
Save dancek/7277624 to your computer and use it in GitHub Desktop.
Playing around with the idea of function annotations in Coffeescript
ㅡ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