clojure functions 3

8

Click here to load reader

Upload: jackson-dos-santos-olveira

Post on 31-May-2015

201 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Clojure functions 3

Clojure Example Functions

ilegra - LDCBy Jackson dos Santos

Page 2: Clojure functions 3

Select-keys

user => (prn (select-keys {:a 1 :b 2 :c 3} [:a :b]))

{:b 2, :a 1}

nil

Page 3: Clojure functions 3

shuffle

user => (shuffle '(1 2 3 4 5 6))

[1 6 4 5 3 2]

Page 4: Clojure functions 3

Set-error-handler - set-error-mode(def bond (agent 1))

(defn handle-log-error [the-agent the-err]

(println (str "the Agent " the-agent " threw the exception " the-err))

)

(set-error-handler! bond handle-log-error)

(set-error-mode! bond :fail)

(send bond / 0)

Page 5: Clojure functions 3

some-fn

user => ((some-fn odd?) 2 4 6)

=> false

It works just for clojure 1.3....

Page 6: Clojure functions 3

4Clojure Problems Solved

Page 7: Clojure functions 3

4Clojure Problems Solved

Page 8: Clojure functions 3

4Clojure Problems Solved