在 Clojure 社群的一個說法:「同樣的工程師使用 Java 來開發軟體、使用 Nodejs 來開發軟體、使用 Clojure 來開發同樣軟體所花費的時間,大約是:5:3:1。」
-
conj: conj list ,conj vector ,conj map ,conj set
-
Intros to sequence, function
-
function 的練習 double down https://4clojure.oxal.org/#/problem/15
-
if 的練習 https://4clojure.oxal.org/#/problem/162 判斷 nil value https://4clojure.oxal.org/#/problem/134
-
教 map/filter/reduce
- map 讓你把對「純量」定義的變換,改成對「向量」來定義
- filter 讓你對「線性集合」來做篩選
- reduce -> monoid 的概念 map https://4clojure.oxal.org/#/problem/17 filter https://4clojure.oxal.org/#/problem/18 reduce https://4clojure.oxal.org/#/problem/64
繪圖來說明、函數是如何運作的。 reduce 要使用「魚骨圖」
-
教 let https://4clojure.oxal.org/#/problem/36 https://4clojure.oxal.org/#/problem/35
-
教 vector destructuring https://4clojure.oxal.org/#/problem/52
-
教 map destructuring
-
教 non-destructuring 的方式取得 collection 的內容
nth
,get
- keyword as function
- vocabulary:
when
/dec
/inc
- simple recursive
https://4clojure.oxal.org/#/problem/57 - 條件判斷:
empty?
,zero?
,nil?
,contains?
- 容器操作:
concat
,merge
- 寫遞迴函數三原則:
- 要去想,什麼是終止條件
- 要去想,怎麼遞迴
- 在做 informal reasoning 的時候,要切換 purpose view
- recursive 與「數學歸納法」的關系~
- 函數命名原則
- 費波納西 & memoize
相關練習:
Last
https://4clojure.oxal.org/#/problem/19
Penultimate
https://4clojure.oxal.org/#/problem/20
Nth
https://4clojure.oxal.org/#/problem/21
Count a sequence
https://4clojure.oxal.org/#/problem/22
Reverse a sequence
https://4clojure.oxal.org/#/problem/23
- 解釋解題的原則
- Solve the question by remembering the Clojure function name. For example,
frequencies. - Solve the question by using some sequence questions: map, filter
- Solve the question by using advanced sequence skill: dec dimension (
mapcat
), inc dimension (range
) - Solve the question by using reduce.
- Solve the question by using recursion.
- Solve the question by using mutual recursion. (interpreter)
- Solve the question by remembering the Clojure function name. For example,
- Abstraction level: 以 BFS 為例,考慮以下列三種不同的方式來實作
- Imperative Programming
- Functional Programming - immutable collection/sequence abstraction & library
- Declarative Programming - treewalk interpreter & DSL/ leverage embedded SQL
- 解釋 seq abstraction 的重要性, 比較 lodash library
- git
- neovim
- tmux
- clj-kondo
- cljfmt
- babashka
- sdkman (用來安裝 java)
- Clojure CLI
- Conjure
- vim-sexp
- go to definition
- namespace, require,
def
,defn
- 何謂 side effects:
slurp
,print
- Dependency Injection
- lazy evaluation 與
dorun
;; write a hello world using babashka
- EDN format,
edn/read-string
- string, keyword, symbol
- the manipulation of hash-map
assoc
,dissoc
,merge
,empty
,into
,zipmap
;; write a CLI program reading config.edn
- variable naming: x, xs, coll, m, ms, f
- Tree manipulation:
postwalk
- Functional programming 常用函數:
mapcat
,partition
,group-by
,apply
;; write a CLI program using above skill
- Clojure error message
- How to debug
- 以實際案例來學習
- walking skeleton first
- 最常用的一些 libraries:
- read config files
- http request
- SQL database
- basic web backend steup
- CheatSheet
- neil
Online REPL for quick start