Clojure lightning talk

Post on 08-May-2015

453 views 0 download

description

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

Transcript of Clojure lightning talk

LDC

5 clojures funcionsSet - Rearrange

dorun doallswap!

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.

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.

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.

Java calling Clojure