Re: agents returning nil by default

2010-05-20 Thread Anders Rune Jensen
On Thu, May 20, 2010 at 2:26 PM, Daniel Werner wrote: > On 20 May 2010 11:42, Anders Rune Jensen wrote: >> The algorithm: >> >> (defn change-state [cur-state] >>   (when (> (:value cur-state) 10) >>      (assoc cur-state :message "danger, danger"))) >> >> How I'd have to write it when using an ag

Re: agents returning nil by default

2010-05-20 Thread Daniel Werner
On 20 May 2010 11:42, Anders Rune Jensen wrote: > The algorithm: > > (defn change-state [cur-state] >   (when (> (:value cur-state) 10) >      (assoc cur-state :message "danger, danger"))) > > How I'd have to write it when using an agent: > > (defn change-state [cur-state] >   (cond (> (:value cur

Re: agents returning nil by default

2010-05-20 Thread Anders Rune Jensen
On Thu, May 20, 2010 at 10:40 AM, Rasmus Svensson wrote: > 2010/5/10 Anders Rune Jensen >> >> [...] But I was a little surprised to find out that by >> default, if you don't return anything, it will set the value of the >> agent to nil. [...] > > Firstly, all clojure functions always return somet

Re: agents returning nil by default

2010-05-20 Thread Rasmus Svensson
2010/5/10 Anders Rune Jensen > [...] But I was a little surprised to find out that by > default, if you don't return anything, it will set the value of the > agent to nil. [...] > Firstly, all clojure functions always return something. Some forms, such as 'cond' and 'when', return nil as a defau