Commits

yongchao li  committed 4f6f45d

new test code

  • Participants
  • Parent commits 1f721e4

Comments (0)

Files changed (2)

File anonymous-fun.clj

+(def total-cost (fn [item-cost number-of-items] (* item-cost number-of-items)))
+
+(println (total-cost 10 2))
+
+(def users [
+	{:username "ivan"
+		:balance 175.00
+		:member-since "2001-2-6"}
+	{:username "lily"
+		:balance 200.34
+		:member-since "2001-4-5"}])
+
+(println (map (fn [user] (user :member-since)) users))
+(println (map #(% :member-since) users));shortcut
+

File dynamic-scope-var.clj

+(def ^:dynamic eval-me 10);(def *eval-me* 10)
+(defn print-the-var [label]
+	(println label eval-me))
+
+(print-the-var "A:")
+
+(binding [eval-me 20]
+	(print-the-var "B:")
+	(binding [eval-me 30]
+		(print-the-var "C:"))
+	(print-the-var "D:"))
+
+(print-the-var "E:")