Skip to content

Instantly share code, notes, and snippets.

@fogus
Created September 7, 2010 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fogus/568890 to your computer and use it in GitHub Desktop.
Save fogus/568890 to your computer and use it in GitHub Desktop.
(defn sqr [n]
"Squares a number"
(* n n))
(sqr 5)
;=> 25
(alter-var-root
(var sqr) ; var to alter
(fn [f] ; fn to apply to the var's value
#(do (println "Squaring" %) ; returns a new fn wrapping old fn
(f %))))
(sqr 5)
; Squaring 5
;=> 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment