Skip to content

Instantly share code, notes, and snippets.

@yangsu
Forked from sudowork/clojure-anonymous-fn.clj
Created April 16, 2013 18:53
Show Gist options
  • Save yangsu/5398538 to your computer and use it in GitHub Desktop.
Save yangsu/5398538 to your computer and use it in GitHub Desktop.
Clojure Anonymous Function Example
; defining a function to square a number
user=> (defn square [x] (* x x))
#'user/square
user=> (square 3)
9
; now using an anonymous function
user=> (def square2 (fn [x] (* x x)))
#'user/square2
user=> (square2 3)
9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment