程序设计的美学都在这里了。
贴一小段笔记:
nil: nil
char: \c
or (char c)
number: 1
or (num 1)
string: "abc"
or (str abc)
???
keyword: :a
or (keyword "a")
symbols: 'a
or (quote a)
boolean: false
or (boolean false)
list: '(1 2 3)
or (list 1 2 3)
vector: [1 2 3]
or (vector 1 2 3)
hash: {:a 1, :b 2}
or (hash-map :a 1 :b 2)
set: #{1 2 3}
or (hash-set 1 2 3)
ASeq LazySeq
Seqable null Iterable Array CharSequence Map
(first coll)
(rest coll)
(cons item coll)
range
user=> (range 10) (0 1 2 3 4 5 6 7 8 9) user=> (range 1 10) (1 2 3 4 5 6 7 8 9) user=> (range 1 10 2) (1 3 5 7 9)
repeat
user=> (repeat 10) (10 10 10 10 10 10 10 10 10 10 ...) user=> (repeat 1 10) (10)
iterate
user=> (iterate inc 1) (1 2 3 4 5 6 7 8 9 10 ...)
take
user=> (take 1 (repeat 10)) (10)
map
user=> (map #(* % 2) (range 1 10)) (2 4 6 8 10 12 14 16 18)
reduce
user=> (reduce + (range 10)) 45
for
user=> (for x (range 1 10)) (2 4 6 8 10 12 14 16 18)
filter
user=> (filter even? (range 10)) (0 2 4 6 8)
remove
user=> (remove even? (range 10)) (1 3 5 7 9)
replace
user=> (replace [1 2 3 4 5] [4 3 2 1 0]) [5 4 3 2 1] user=> (replace ["a" ">" "b"] [2 1 0]) ["b" ">" "a"]
cycle
user=> (cycle [0 1 2]) (0 1 2 0 1 2 0 1 2 0 ...)
reverse
user=> (reverse (range 10)) (9 8 7 6 5 4 3 2 1 0)
shuffle
user=> (shuffle (range 10)) [1 4 8 0 6 3 9 2 5 7]
sort
user=> (sort (shuffle (range 10))) (0 1 2 3 4 5 6 7 8 9)
flatten
user=> (flatten '(1 2 3 7 8 [9])) (1 2 3 4 5 6 7 8 9)
distinct
user=> (distinct [1 2 3 1 2]) (1 2 3)
interleave
user=> (interleave [:a :b] [1 2]) (:a 1 :b 2) user=> (interleave :a :b :c) (:a 1 :b 2 :c 3)
interpose
(interpose "," [:a :b :c]) (:a "," :b "," :c) user=> (apply str (interpose ", " [:a :b :c])) ":a, :b, :c"
into
user=> (into (reverse (range 5)) (range 5 10)) (9 8 7 6 5 4 3 2 1 0)
split-at
user=> (split-at 5 (range 10)) [(0 1 2 3 4) (5 6 7 8 9)]
partition
user=> (partition 2 (range 10)) ((0 1) (2 3) (4 5) (6 7) (8 9)) user=> (partition 2 3 (range 10)) ((0 1) (3 4) (6 7)) user=> (partition 2 3 10) ((0 1) (3 4) (6 7) (9 10))
user=> (-> 5 (+ 2) (- 3) (* 2)) 8
user=> (-> "x y z" .toUpperCase (.replace "X" "A") (.split " ") first) "A"
新纪元下你还抢着学 Go? 醒醒吧!...
Clojure Document: http://clojure.org/documentation
Clojure Docs: http://clojuredocs.org/quickref/Clojure%20Core
Clojure Cheatsheet : https://github.com/jafingerhut/clojure-cheatsheets/tree/master/pdf
Clojure koans : https://github.com/functional-koans/clojure-koans
Clojure ring( like rack ): https://github.com/ring-clojure/ring
From Narkoz
Clojure style guide: https://github.com/bbatsov/clojure-style-guide
Ruby + Clojure: https://github.com/rouge-lang/rouge
发文前在本地打底稿多么地重要!