Skip to content

Instantly share code, notes, and snippets.

@ayato-p
Created June 4, 2014 23:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayato-p/5b1eb4f6fb9da69e5fc2 to your computer and use it in GitHub Desktop.
Save ayato-p/5b1eb4f6fb9da69e5fc2 to your computer and use it in GitHub Desktop.
(let [a (inc (rand-int 6)),
b (inc (rand-int 6))]
(println (format "You rolled a %s and b %s" a b))
(+ a b)))
(defn hypot
[x, y]
(let [x2 (* x x),
y2 (* y y)]
(Math/sqrt (+ x2 y2))))
(hypot 10)
(def v [42, "foo", 99.2, [5, 12]])
(let [[x, _, z, :as hoge] v]
hoge)
(def v [42 "foo" 99.2 [5 12]])
(let [[x, y, z] v]
(+ x z))
(let [[x, _, _, [y, z]] v]
(+ x y z))
(let [[x & r] v]
r)
((fn rec-test [l]
(let [[x & rest] l]
(if (nil? rest)
(print x)
(recur rest)))) [1 2 3 4 5 6])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment