Comparison with atom values

2015-02-12 Thread Newbie
I am trying to compare atom values with numbers. For e.g. - (def a (atom 0)) (print a) gives -- #Atom@2bcca11e: 0 (= a 0) gives -- false How do I make this work? How do I compare 0 with the atom value? I want to do the same for a string to? I cannot use compare-and-set! for my situation.

Re: Comparison with atom values

2015-02-12 Thread adrian . medina
You must deref (https://clojuredocs.org/clojure.core/deref) reference values to get the data inside of it. (= @a 0) is the same as saying (= (deref a) 0) Hope this helps! On Thursday, February 12, 2015 at 2:27:39 PM UTC-5, Newbie wrote: I am trying to compare atom values with numbers. For

Re: Comparison with atom values

2015-02-12 Thread Max Countryman
To compare the value of the atom, you should deref it first. Using deref, you’ll get the current value of the atom: = (deref a) 0 Or using the reader macro: = @a 0 So: = (= @a 0) true Hope that helps, Max On Feb 12, 2015, at 11:27, Newbie yash.a.kel...@gmail.com wrote: I am trying to

Re: Comparison with atom values

2015-02-12 Thread Timothy Baldridge
deref is used to pull the value out of an atom, ref, or atom (or other reference type). (= (deref a) 0) gives -- true Also there is a shorthand operator: (= @a 0) Timothy On Thu, Feb 12, 2015 at 12:27 PM, Newbie yash.a.kel...@gmail.com wrote: I am trying to compare atom values with