Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (defrecord Item [id name description])
  2.  
  3. (def items
  4. (ref [
  5. (->Item "1" "Cookies" "Good tasting!")
  6. (->Item "2" "Blueberries" "Healthy!")
  7.  
  8. ])
  9. )
  10.  
  11. (dosync (commute items ???? ))
  12.  
  13. (commute items #(remove (fn [x](= (:id x) id)) %))
  14.  
  15. (nth (filtered (filter #(= (:id %) id) @items)) 0)
  16.  
  17. (dosync
  18. (commute items
  19. #(mapv (fn [i]
  20. (if (= (:id i) "1")
  21. (assoc i :name "foo")
  22. i))
  23. %)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement