More Related Content Similar to Introduction to Clojure - EDGE Lviv (20) Introduction to Clojure - EDGE Lviv10. Fun with code (Quick Sort)
❖
APL: qsort ← {1≥⍴⍵:⍵⋄e←⍵[?⍴⍵]⋄ (∇(⍵<e)/⍵) , ((⍵=e)/⍵) , ∇(⍵>e)/⍵}
❖
J: quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)
❖
Clojure:
(defn qsort [L]
(if (empty? L)
'()
(let [[pivot & L2] L]
(lazy-cat (qsort (for [y L2 :when (< y pivot)] y))
(list pivot)
(qsort (for [y L2 :when (>= y pivot)] y))))))
13. Some facts
❖
Typing: dynamic, strong
❖
(Almost) no syntax (S-expressions)
❖
Lisp-1
❖
Persistent data structures
❖
Laziness
❖
Less brackets than in Java :)
14. ❖
(list 1 2 3) ‘(1 2 3)
❖
(vector 1 2 3) [1 2 3]
❖
(hash-map :a 1 :b 2) {:a 1, :b 2}
❖
(hash-set 1 2 3) #{1 2 3}
16. ❖
LISP + JVM foundation
❖
Simplicity - core of the language design
❖
Best parallelism primitives
❖
Modular libraries
❖
Code is data
❖
DSL
17. Best answers to “Why?”
question
❖
http://www.infoq.com/presentations/Are-We-There-Yet-Rich
❖
http://www.youtube.com/watch?v=f84n5oFoZBc
❖
http://www.infoq.com/presentations/Simple-Made-Easy
❖
http://www.infoq.com/presentations/Value-Values
❖
http://www.youtube.com/watch?v=ROor6_NGIWU
❖
http://www.infoq.com/presentations/DesignComposition-Performance