File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ; ; from http://clojure-doc.org/articles/tutorials/introduction.html
2+
3+ (require '[clojure.string :as str])
4+ (def the-answer 42 )
5+ [1 2 3 ] ; A vector
6+ [1 :two " three" ]
7+ {:a 1 :b 2 }
8+ #{:a :b :c }
9+ '(1 2 3 )
10+ (def my-stuff [" shirt" " coat" " hat" ]) ; this is more typical usage.
11+
12+ (my-func (my-func2 arg1
13+ arg2)
14+ (other-func arg-a
15+ (foo-bar arg-x
16+ arg-y
17+ (+ arg-xx
18+ arg-yy
19+ arg-zz))
20+ arg-b))
21+ '(+ 1 2 3 )
22+ ; ; ⇒ (+ 1 2 3)
23+ (let [width 10
24+ height 20
25+ thickness 2 ]
26+ (println " hello from inside the `let`." )
27+ (* width
28+ height
29+ thickness))
30+
31+ ; ; Vectors
32+ (def v [:a :b :c ])
33+ (def li '(:a :b :c ))
34+ (conj v :d ) ; ⇒ [:a :b :c :d]
35+ (conj li :d ) ; ⇒ (:d :a :b :c)
36+
37+ v ; ⇒ is still [:a :b :c]
38+ li ; ⇒ is still (:a :b :c)
39+
40+ ; ; Maps
41+ (def m {:a 1 :b 2 })
42+ (assoc m :c 3 ) ; ⇒ {:a 1 :c 3 :b 2}
43+ (dissoc m :b ) ; ⇒ {:a 1}
44+
45+ (def my-atom (atom {:foo 1 }))
46+ ; ; ⇒ #'user/my-atom
47+ @my-atom
48+ ; ; ⇒ {:foo 1}
49+ (swap! my-atom update-in [:foo ] inc)
50+ ; ; ⇒ {:foo 2}
51+ @my-atom
52+ ; ; ⇒ {:foo 2}
You can’t perform that action at this time.
0 commit comments