On 8 July 2014 at 17:40:49, Cecil Westerhof (cldwester...@gmail.com) wrote:
> > In Clojure you can define a local constant with let, but I need  
> a variable (I think).

They are not constants. Locals can be "overwritten" but their data structures
are immutable (by default).

> I want to do the following. I have a function that checks several  
> things. Every time an error is found I want to set the variable  
> errors to:
> (concat errors new-error)
>  
> Is this possible? Or is there a better way to do this?

You can do that with loop/recur or an atom. The key is to understand
that in Clojure, values and references are separate, and references
can be mutated but in a particular, concurrency-aware way:

http://clojure-doc.org/articles/language/concurrency_and_parallelism.html#identity/value-separation-("on-state-and-identity")
--  
MK

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to