Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 11:28 PM, Alan Malloy wrote: > but if you look at the post There is no call for taking a rude tone. I correctly answered the question as originally posed. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: On using atoms together with side effect functions

2012-01-06 Thread Alan Malloy
On Jan 6, 7:32 pm, Cedric Greevey wrote: > On Fri, Jan 6, 2012 at 10:22 PM, Alan Malloy wrote: > > On Jan 6, 6:16 pm, Cedric Greevey wrote: > >> On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: > >> > On Jan 6, 12:56 pm, Jozef Wagner wrote: > >> >> Thank you, > > >> >> But the things are mor

Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 10:22 PM, Alan Malloy wrote: > On Jan 6, 6:16 pm, Cedric Greevey wrote: >> On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: >> > On Jan 6, 12:56 pm, Jozef Wagner wrote: >> >> Thank you, >> >> >> But the things are more complicated. In my case, I need to update the atom

Re: On using atoms together with side effect functions

2012-01-06 Thread Alan Malloy
On Jan 6, 6:16 pm, Cedric Greevey wrote: > On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: > > On Jan 6, 12:56 pm, Jozef Wagner wrote: > >> Thank you, > > >> But the things are more complicated. In my case, I need to update the atom > >> with the result of a (native) function which unfortunat

Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: > On Jan 6, 12:56 pm, Jozef Wagner wrote: >> Thank you, >> >> But the things are more complicated. In my case, I need to update the atom >> with the result of a (native) function which unfortunately also performs >> some side effects and cannot b

Re: On using atoms together with side effect functions

2012-01-06 Thread Alan Malloy
On Jan 6, 12:56 pm, Jozef Wagner wrote: > Thank you, > > But the things are more complicated. In my case, I need to update the atom > with the result of a (native) function which unfortunately also performs > some side effects and cannot be split in two. > > Updated example: > > (def state {:resul

Re: On using atoms together with side effect functions

2012-01-06 Thread Jozef Wagner
Thank you, But the things are more complicated. In my case, I need to update the atom with the result of a (native) function which unfortunately also performs some side effects and cannot be split in two. Updated example: (def state {:result nil :input [1 2 3]}) (defn update-item! [item]

Re: On using atoms together with side effect functions

2012-01-06 Thread Dave Ray
On Fri, Jan 6, 2012 at 3:02 PM, Jozef Wagner wrote: > Consider this contrived piece of code: > > (def aval (atom {:dumped false :contents "hello world"})) > > (defn update! >   [item] >   (when-not (:dumped item) >     (spit "a.out" (:contents item) :append true) >     (assoc item :dumped true)))

On using atoms together with side effect functions

2012-01-06 Thread Jozef Wagner
Consider this contrived piece of code: (def aval (atom {:dumped false :contents "hello world"})) (defn update! [item] (when-not (:dumped item) (spit "a.out" (:contents item) :append true) (assoc item :dumped true))) How should I correctly call update! ? Each of following two calls ha