So the validation takes place after alter messages conj msg in the
add-message function?
On Jun 24, 4:48 pm, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
alter calls conj on [] (which is kept as a vector) since it is the
initial content of the messages ref. So the content of messages is a
Hi,
On Jun 25, 8:12 am, michele michelemen...@gmail.com wrote:
So the validation takes place after alter messages conj msg in the
add-message function?
Well. in between. It takes place after the conj, but before the
alter. The value is taken from the ref and modified by the function
you
Ok, then I understand why it didn't work, but that means that the
struct (that is sent by the add-message function) is put in a sequence
somewhere on the way to being validated. Is this right, and where does
this happen?
;All the relevant code
(defstruct message :sender :text)
(def
You are correct. The struct is a single message. The messages object holds a
ref to N of them (initially an empty vector).
Individual messages are added by alter ... conj in add-message.
Stu
Ok, then I understand why it didn't work, but that means that the
struct (that is sent by the
Hi,
alter calls conj on [] (which is kept as a vector) since it is the
initial content of the messages ref. So the content of messages is a
seqable thing and not a single message.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To
In the book Programming Clojure (p2_0, pdf, page 185) Adding
Validation to Refs there is this code:
(def validate-message-list (partial every? #(and (:sender %) (:text
%
This works fine as a validator, but when I try the code directly - not
as a validator - it returns false. I also tested
Hi Michele,
Pass a sequence of maps, not just a map:
(every? #(:x %) [{:x s}])
- true
Cheers,
Stu
In the book Programming Clojure (p2_0, pdf, page 185) Adding
Validation to Refs there is this code:
(def validate-message-list (partial every? #(and (:sender %) (:text
%
This works