Clojure lightning talk

15
LDC

description

Quick talk about some core clojure functions and some 4clojure solutions

Transcript of Clojure lightning talk

Page 1: Clojure lightning talk

LDC

Page 2: Clojure lightning talk

5 clojures funcionsSet - Rearrange

dorun doallswap!

Page 3: Clojure lightning talk

user=> (doc dorun)

1. lazy sequences produced via functions that have side effects2. dorun can be used to force any other side effects. Walks through the successive nexts ofthe seq, does not retain the head and returns nil.

Page 4: Clojure lightning talk
Page 5: Clojure lightning talk

doallfunction

Usage: (doall coll) (doall n coll)

1. lazy sequences are produced via functions that have side effects2. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time.

Page 6: Clojure lightning talk
Page 7: Clojure lightning talk

swap!function

Usage: (swap! atom f) (swap! atom f x) (swap! atom f x y) (swap! atom f x y & args)

* Atomically swaps the value of atom to be: (apply f current-value-of-atom args).

* f should be free of side effects.

* Returns the value that was swapped in.

Page 8: Clojure lightning talk
Page 9: Clojure lightning talk
Page 10: Clojure lightning talk
Page 11: Clojure lightning talk
Page 12: Clojure lightning talk
Page 13: Clojure lightning talk
Page 14: Clojure lightning talk
Page 15: Clojure lightning talk

Java calling Clojure