0
LDC 14/11/2011
3 clojures funcions      Set - Rearrangereset!compare-and-set!commute
user=> (doc reset!)-------------------------([atom newval])  Sets the value of atom to newval without regard for thecurren...
compare-and-set!-------------------------([atom oldval newval])  Atomically sets the value of atom to newval if and only i...
commute-------------------------([ref fun & args])  Must be called in a transaction. Sets the in-transaction-value of reft...
partition-*
Clojure LDC 5
Clojure LDC 5
Clojure LDC 5
Clojure LDC 5
Upcoming SlideShare
Loading in...5
×

Clojure LDC 5

267

Published on

Presented functions:
- commute
- compare-and-set!
- reset!

3 4clojure problem solutions

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
267
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Clojure LDC 5"

  1. 1. LDC 14/11/2011
  2. 2. 3 clojures funcions Set - Rearrangereset!compare-and-set!commute
  3. 3. user=> (doc reset!)-------------------------([atom newval]) Sets the value of atom to newval without regard for thecurrent value. Returns newval.
  4. 4. compare-and-set!-------------------------([atom oldval newval]) Atomically sets the value of atom to newval if and only ifthe current value of the atom is identical to oldval. Returnstrue if set happened, else false
  5. 5. commute-------------------------([ref fun & args]) Must be called in a transaction. Sets the in-transaction-value of refto: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref. At the commit point of the transaction, sets the value of ref to be: (apply fun most-recently-committed-value-of-ref args) Thus fun should be commutative, or, failing that, you must accept last-one-in-wins behavior. commute allows for more concurrencythan ref-set.
  6. 6. partition-*
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×