Skip to content

Instantly share code, notes, and snippets.

@mmcgrana
Created February 27, 2010 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmcgrana/316946 to your computer and use it in GitHub Desktop.
Save mmcgrana/316946 to your computer and use it in GitHub Desktop.
; orignal code
(def putinme (ref {}))
(for [itrId #{"A1HHSCH9YA57GL" "A13706T7S3HLRQ" "A2QNYO5VK24YE4"} ]
(dosync ( ref-set putinme ( assoc @putinme itrId {:val 1} )))
)
@putinme
; for is lazy, body here is never executed; consider doseq
; use alter to make more concise
; you may want atoms instead of refs
; suggested code (for refs)
(def putinme (ref {}))
(doseq [itr-id #{"A1HHSCH9YA57GL" "A13706T7S3HLRQ" "A2QNYO5VK24YE4"}]
(dosync (alter putinme assoc itr-id {:val 1})))
@putinme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment