conj is used in (conj coll item), for example (conj #{} “Stu”).
But, I found this example in ‘Programming Clojure’ book page16.
(alter visitors conj username)
I guess (conj visitors username) would be the correct usage. What’s the secret?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The “secret” is that alter is a special function that is called in a transaction on a ref, and it has the effect of inserting the current value of the ref as the first parameter to whichever function is supplied as its second argument.
In fact the normal usage for conj with a ref would be:
So alter roughly translates as follows: