This document provides an overview of Clojure 101 and introduces various Clojure concepts including web apps, GUIs, mobile development, terminals, animation, games, Arduino, health, and space. It demonstrates basic Clojure data types, functions, macros, pattern matching, unit testing, JSON/HTML creation, XML reading, and using goroutines.
59. def fib(0) do 0 end
def fib(1) do 1 end
def fib(n) do
fib(n-1) + fib(n-2)
end
PATTERN MATCHING
(defn-match fib
([0] 1)
([1] 1)
([?n] (+ (fib (- n 1))
(fib (- n 2)))))
60. for i := 0; i < 10; i++ {
go func(i int) {
sleep := time.Duration(rand.Intn(1000))
time.Sleep(sleep * time.Millisecond)
fmt.Println(i)
}(i)
}
GOROUTINES
(for [i (range 10)]
(go
(Thread/sleep (rand-int 1000))
(println i)))